pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedJDBC and DriverManager
3+ messages / 3 participants
[nested] [flat]
* JDBC and DriverManager
@ 1998-07-02 18:57 Jeffrey Napolitano <jnapoli@setech.com>
1998-07-02 19:21 ` Re: [INTERFACES] JDBC and DriverManager Felix Morley Finch <felix@crowfix.com>
0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey Napolitano @ 1998-07-02 18:57 UTC (permalink / raw)
To: pgsql-interfaces
Okay...the below code compiles fine, but when it runs, it throws the
SQLException at the DriverManager line (as you can see, everything below
is commented out). There is indeed a datasource "bugs", and PostgreSQL
is running on the local machine. There is no password needed to access
the database, and I can access "bugs" interactively with psql. Am I not
importing a package...?
I need help...am lost to why it throws the SQLException.
------------------------------------------------------------
import java.util.*;
import java.io.*;
import java.sql.*;
public class HopeSprings {
public static void main(String[] args) {
String url = "jdbc:postgresql:bugs";
Connection con;
String createString;
createString = "create table STUFF " + "(NAME
varchar(30), " + "IDNUMBER int)";
Statement stmt;
try {
Class.forName("postgresql.Driver");
}
catch(ClassNotFoundException except) {
System.out.println("ClassNotFound: didn't
work");
}
try {
con = DriverManager.getConnection(url);
//stmt = con.createStatement();
//stmt.executeUpdate(createString);
//stmt.close();
//con.close();
}
catch(SQLException sqlexcept) {
System.out.println("The SQL Exception was
thrown");
}
} //End of main in JDBC_Connection class
} //End of JDBC_Connection class bracket
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [INTERFACES] JDBC and DriverManager
1998-07-02 18:57 JDBC and DriverManager Jeffrey Napolitano <jnapoli@setech.com>
@ 1998-07-02 19:21 ` Felix Morley Finch <felix@crowfix.com>
0 siblings, 0 replies; 3+ messages in thread
From: Felix Morley Finch @ 1998-07-02 19:21 UTC (permalink / raw)
To: pgsql-interfaces
>>In article <359BD804.6D60872F@setech.com>, Jeffrey Napolitano <jnapoli@setech.com> writes:
> I need help...am lost to why it throws the SQLException.
It would help to print the exception...
> catch(SQLException sqlexcept) {
> System.out.println("The SQL Exception was thrown");
System.out.println("The SQL Exception was " + sqlexcept);
or something like that, I think (brain in assembly mode right now).
--
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
Felix Finch: scarecrow repairman & rocket surgeon / felix@crowfix.com
PGP = 91 B3 94 7C E9 E8 76 2D E1 63 51 AA A0 48 89 2F ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [INTERFACES] JDBC and DriverManager
@ 1998-07-03 19:05 llestat <llestat@ibm.net>
0 siblings, 0 replies; 3+ messages in thread
From: llestat @ 1998-07-03 19:05 UTC (permalink / raw)
To: Jeffrey Napolitano <jnapoli@setech.com>; +Cc: pgsql-interfaces
Go ahead and pass it a user name and password I had a similar problem where all
JDBC programs would refuse to connect even though the Database was not password
protected just use yur admin name and anything for the password.
- Richard
On Thu, 02 Jul 1998, Jeffrey Napolitano wrote:
>Okay...the below code compiles fine, but when it runs, it throws the
>SQLException at the DriverManager line (as you can see, everything below
>is commented out). There is indeed a datasource "bugs", and PostgreSQL
>is running on the local machine. There is no password needed to access
>the database, and I can access "bugs" interactively with psql. Am I not
>importing a package...?
>
>I need help...am lost to why it throws the SQLException.
>
>------------------------------------------------------------
>import java.util.*;
>import java.io.*;
>import java.sql.*;
>
>public class HopeSprings {
> public static void main(String[] args) {
> String url = "jdbc:postgresql:bugs";
> Connection con;
> String createString;
> createString = "create table STUFF " + "(NAME
>varchar(30), " + "IDNUMBER int)";
> Statement stmt;
>
> try {
> Class.forName("postgresql.Driver");
> }
> catch(ClassNotFoundException except) {
> System.out.println("ClassNotFound: didn't
>work");
> }
>
> try {
> con = DriverManager.getConnection(url);
> //stmt = con.createStatement();
> //stmt.executeUpdate(createString);
> //stmt.close();
> //con.close();
> }
> catch(SQLException sqlexcept) {
> System.out.println("The SQL Exception was
>thrown");
> }
> } //End of main in JDBC_Connection class
>} //End of JDBC_Connection class bracket
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~1998-07-03 19:05 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1998-07-02 18:57 JDBC and DriverManager Jeffrey Napolitano <jnapoli@setech.com>
1998-07-02 19:21 ` Felix Morley Finch <felix@crowfix.com>
1998-07-03 19:05 Re: [INTERFACES] JDBC and DriverManager llestat <llestat@ibm.net>
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