pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedplease checkits urgent
2+ messages / 2 participants
[nested] [flat]
* please checkits urgent
@ 2007-07-17 12:02 durga prasad <kdgprasad@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: durga prasad @ 2007-07-17 12:02 UTC (permalink / raw)
To: pgsql-jdbc
hi
iam durga prasad,
iam using Postgresql8.2 when iam trying to connect
the driver is not working (org.postgresql.Driver) can please send me the
driver class of java to connect to DB,please revert to me immediately
following code i have used: pls correct and revert tome
import java.sql.*;
import java.io.*;
class Conc {
public static void main(String[] args) throws Exception {
//Class.forName(" JDBC Driver goes here");
Class.forName("org.postgresql.Driver");
//jdbc:postgresql://host:port/database
Connection con=DriverManager.getConnection
("jdbc:postgresql://localhost:5432/postgres","poks","aqswdefr");
Statement stmt=con.createStatement();
//system.out.println("Creating Table---->");
//stmt.executeUpdate("Create table emp(eid int, ename varchar2(12))");
System.out.println("Inserting row--->");
stmt.executeUpdate("Insert into emp values('bbbb',2)");
System.out.println("One row is Inserted.....");
System.out.println("Getting data ---->");
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2));
rs.close();
stmt.close();
con.close();
} //main()
} //class
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: please checkits urgent
@ 2007-07-17 18:11 Guy Rouillier <guyr-ml1@burntmail.com>
parent: durga prasad <kdgprasad@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: Guy Rouillier @ 2007-07-17 18:11 UTC (permalink / raw)
To: pgsql-jdbc
durga prasad wrote:
> hi
>
> iam durga prasad,
>
> iam using Postgresql8.2 when iam trying to
> connect the driver is not working (org.postgresql.Driver) can please
> send me the driver class of java to connect to DB,please revert to me
> immediately following code i have used: pls correct and revert tome
>
You would get more relevant responses if you told us the error you are
receiving. Most likely, you are encountering a classpath problem. Make
sure the PG JAR file is in your runtime classpath. Your code below
looks fine.
>
>
>
> import java.sql.*;
> import java.io.*;
> class Conc {
> public static void main(String[] args) throws Exception {
>
> //Class.forName(" JDBC Driver goes here");
>
> Class.forName("org.postgresql.Driver");
>
> //jdbc:postgresql://host:port/database
>
> Connection
> con=DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres","poks","aqswdefr");
>
>
>
> Statement stmt=con.createStatement();
>
> //system.out.println("Creating Table---->");
> //stmt.executeUpdate("Create table emp(eid int, ename varchar2(12))");
>
> System.out.println("Inserting row--->");
> stmt.executeUpdate("Insert into emp values('bbbb',2)");
> System.out.println("One row is Inserted.....");
>
> System.out.println("Getting data ---->");
>
> ResultSet rs=stmt.executeQuery("select * from emp");
>
> while(rs.next())
> System.out.println(rs.getInt(1)+" "+rs.getString(2));
>
> rs.close();
> stmt.close();
> con.close();
> } //main()
> } //class
>
--
Guy Rouillier
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2007-07-17 18:11 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-07-17 12:02 please checkits urgent durga prasad <kdgprasad@gmail.com>
2007-07-17 18:11 ` Guy Rouillier <guyr-ml1@burntmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox