pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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>&nbsp;</DIV> <DIV>import java.sql.*;</DIV> <DIV>public class DBConnection<BR>{</DIV> <DIV>&nbsp;public void connection()<BR>&nbsp;{<BR>&nbsp;&nbsp;String pgsqlDriver = "org.postgresql.Driver";<BR>&nbsp;&nbsp;//String pgsqlURL = "jdbc:postgresql://host:5432/mydb";<BR>&nbsp;&nbsp;String pgsqlURL = "jdbc:postgresql://192.168.0.165/testdb";</DIV> <DIV>&nbsp;&nbsp;String pgsqlUser = "User";<BR>&nbsp;&nbsp;String pgsqlPW = "password";<BR>&nbsp;&nbsp;String pgsqlQuery = null;<BR>&nbsp;&nbsp;Connection pgsqlConn = null;<BR>&nbsp;&nbsp;Statement pgsqlStatement = null;<BR>&nbsp;&nbsp;ResultSet pgsqlRSet = null;</DIV> <DIV>&nbsp;&nbsp;try<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp; Class.forName(pgsqlDriver);<BR>&nbsp;&nbsp;&nbsp; pgsqlConn = DriverManager.getConnection(pgsqlURL, pgsqlUser, pgsqlPW);<BR>&nbsp;&nbsp;&nbsp; pgsqlStatement = pgsqlConn.createStatement();<BR>&nbsp;&nbsp;&nbsp; pgsqlQuery = "SELECT * FROM users;";<BR>&nbsp;&nbsp;&nbsp; pgsqlRSet = pgsqlStatement.executeQuery(pgsqlQuery);<BR>&nbsp;&nbsp;}</DIV> <DIV>&nbsp;&nbsp;catch (ClassNotFoundException cnfe)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp; System.out.println("Could not load database driver:" + cnfe.getMessage());<BR>&nbsp;&nbsp;}</DIV> <DIV>&nbsp;&nbsp;catch (SQLException sqle)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp; System.out.println("Could not connect to the database: " + sqle.getMessage());<BR>&nbsp;&nbsp;}</DIV> <DIV>&nbsp;&nbsp;finally<BR>&nbsp;&nbsp;{</DIV> <DIV>&nbsp;&nbsp;&nbsp; try<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;if ( pgsqlConn != null )<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;// Close the connection no matter what.<BR>&nbsp;&nbsp;&nbsp;pgsqlConn.close();<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp; }</DIV> <DIV>&nbsp;&nbsp;&nbsp; catch (SQLException sqle)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;System.out.println("Could not connect to the database(2): " + sqle.getMessage());<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;}//finally<BR>&nbsp;}//end connection()</DIV> <DIV>&nbsp;public static void main(String args[])<BR>&nbsp;{<BR>&nbsp;&nbsp;new DBConnection().connection();<BR>&nbsp;}<BR>}//class</DIV> <DIV>&nbsp;</DIV> <DIV>The code is compile well. But here is a runtime problem. The prolem is:</DIV> <DIV>&nbsp;</DIV> <DIV>Could not load database driver :<FONT color=#4040ff>org.postgresql.Driver</FONT></DIV> <DIV><FONT color=#4040ff></FONT>&nbsp;</DIV> <DIV><FONT color=#4040ff>Is there anybody to help me?</FONT></DIV> <DIV><FONT color=#4040ff></FONT>&nbsp;</DIV> <DIV><FONT color=#4040ff>thanking u,</FONT></DIV> <DIV><FONT color=#4040ff>Ripon</FONT></DIV> <DIV>&nbsp;</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

view thread (24+ messages)  latest in thread

Message-ID: <2973583.1060031923212.JavaMail.nobody@wamui07.slb.atl.earthlink.net>
Permalink:  ../2973583.1060031923212.JavaMail.nobody@wamui07.slb.atl.earthlink.net/
Also on:    postgresql.org/message-id/2973583.1060031923212.JavaMail.nobody@wamui07.slb.atl.earthlink.net

 · 

reply

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