From: Scot P. Floess <floess@mindspring.com>
To: Ripon Al Wasim <riponc007@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: Connection problem
Date: Mon, 4 Aug 2003 17:17:50 -0400 (GMT)
Message-ID: <2973583.1060031923212.JavaMail.nobody@wamui07.slb.atl.earthlink.net> (raw)
Do you have the appropriate postgres jar in your class path?
Original message attached.
Attachments:MESSAGE.HTML (text/html, 2.8K) download
<DIV>hello,</DIV>
<DIV>I wanna connet between java and PostgreSQL. Here is the code:</DIV>
<DIV> </DIV>
<DIV>import java.sql.*;</DIV>
<DIV>public class DBConnection<BR>{</DIV>
<DIV> public void connection()<BR> {<BR> String pgsqlDriver = "org.postgresql.Driver";<BR> //String pgsqlURL = "jdbc:postgresql://host:5432/mydb";<BR> String pgsqlURL = "jdbc:postgresql://192.168.0.165/testdb";</DIV>
<DIV> String pgsqlUser = "User";<BR> String pgsqlPW = "password";<BR> String pgsqlQuery = null;<BR> Connection pgsqlConn = null;<BR> Statement pgsqlStatement = null;<BR> ResultSet pgsqlRSet = null;</DIV>
<DIV> try<BR> {<BR> Class.forName(pgsqlDriver);<BR> pgsqlConn = DriverManager.getConnection(pgsqlURL, pgsqlUser, pgsqlPW);<BR> pgsqlStatement = pgsqlConn.createStatement();<BR> pgsqlQuery = "SELECT * FROM users;";<BR> pgsqlRSet = pgsqlStatement.executeQuery(pgsqlQuery);<BR> }</DIV>
<DIV> catch (ClassNotFoundException cnfe)<BR> {<BR> System.out.println("Could not load database driver:" + cnfe.getMessage());<BR> }</DIV>
<DIV> catch (SQLException sqle)<BR> {<BR> System.out.println("Could not connect to the database: " + sqle.getMessage());<BR> }</DIV>
<DIV> finally<BR> {</DIV>
<DIV> try<BR> {<BR> if ( pgsqlConn != null )<BR> {<BR> // Close the connection no matter what.<BR> pgsqlConn.close();<BR> }<BR> }</DIV>
<DIV> catch (SQLException sqle)<BR> {<BR> System.out.println("Could not connect to the database(2): " + sqle.getMessage());<BR> }<BR> }//finally<BR> }//end connection()</DIV>
<DIV> public static void main(String args[])<BR> {<BR> new DBConnection().connection();<BR> }<BR>}//class</DIV>
<DIV> </DIV>
<DIV>The code is compile well. But here is a runtime problem. The prolem is:</DIV>
<DIV> </DIV>
<DIV>Could not load database driver :<FONT color=#4040ff>org.postgresql.Driver</FONT></DIV>
<DIV><FONT color=#4040ff></FONT> </DIV>
<DIV><FONT color=#4040ff>Is there anybody to help me?</FONT></DIV>
<DIV><FONT color=#4040ff></FONT> </DIV>
<DIV><FONT color=#4040ff>thanking u,</FONT></DIV>
<DIV><FONT color=#4040ff>Ripon</FONT></DIV>
<DIV> </DIV><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/evt=10469/*http://sitebuilder.yahoo.com">Yahoo! SiteBuilder</a> - Free, easy-to-use web site design software
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: floess@mindspring.com, riponc007@yahoo.com
Subject: Re: Connection problem
In-Reply-To: <2973583.1060031923212.JavaMail.nobody@wamui07.slb.atl.earthlink.net>
References: <2973583.1060031923212.JavaMail.nobody@wamui07.slb.atl.earthlink.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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