Thread: JDBC driver not found error: Windows XP / JDK1.6.06 / PG8.2.9

JDBC driver not found error: Windows XP / JDK1.6.06 / PG8.2.9

From
"Chandra ASGI Tech"
Date:

I have PostgreSQL 8.2.9 on Windows XP, with JDK 1.6.0_06.   Have got the postgresql-8.2-508.jdbc4.jar  jdbc driver in /lib/ext of the Java folder.

HAve set both the PATH and CLASSPATH aporpriately

My Java code for testing is:

import java.sql.*;

class postgreSQLTest
 {

public static void main (java.lang.String[] args) throws Exception {

try{

Class.forName("org.postgresql.Driver");

Connection con =
DriverManager.getConnection("jdbc:Postgresql://localhost:5432/postgres","postgres","1234");

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from country");

while(rs.next())

{

System.out.println(rs.getString(1)+"<br>");

}

}catch(Exception e){

System.out.println(e);

}

}

}

 

But I get the error
Exception in thread "main" java.lang.NoClassDefFoundError: postgreSQLTest


Any help? Thanks in advance.
 
 
- ChandraASGI

Re: JDBC driver not found error: Windows XP / JDK1.6.06 / PG8.2.9

From
Dave Cramer
Date:
You have used a capital P in the url jdbc:Postgresql://localhost:5432/
postgres","postgres","1234");

Dave
On 1-Jul-08, at 9:28 AM, Chandra ASGI Tech wrote:

> I have PostgreSQL 8.2.9 on Windows XP, with JDK 1.6.0_06.   Have got
> the postgresql-8.2-508.jdbc4.jar  jdbc driver in /lib/ext of the
> Java folder.
>
> HAve set both the PATH and CLASSPATH aporpriately
>
> My Java code for testing is:
>
> import java.sql.*;
>
> class postgreSQLTest
>  {
>
> public static void main (java.lang.String[] args) throws Exception {
>
> try{
>
> Class.forName("org.postgresql.Driver");
>
> Connection con =
> DriverManager.getConnection("jdbc:Postgresql://localhost:5432/
> postgres","postgres","1234");
>
> Statement stmt = con.createStatement();
> ResultSet rs = stmt.executeQuery("select * from country");
>
> while(rs.next())
>
> {
>
> System.out.println(rs.getString(1)+"<br>");
>
> }
>
> }catch(Exception e){
>
> System.out.println(e);
>
> }
>
> }
>
> }
>
>
> But I get the error
> Exception in thread "main" java.lang.NoClassDefFoundError:
> postgreSQLTest
>
>
> Any help? Thanks in advance.
>
>
> - ChandraASGI


Re: JDBC driver not found error: Windows XP / JDK1.6.06 / PG8.2.9

From
Oliver Jowett
Date:
Chandra ASGI Tech wrote:

> But I get the error
> Exception in thread "main" java.lang.NoClassDefFoundError: postgreSQLTest

Your code isn't even running because the JVM can't find your main class.
This isn't anything to do with JDBC, it's basic Java.

-O

Re: JDBC driver not found error: Windows XP / JDK1.6.06 / PG8.2.9

From
"Chandra ASGI Tech"
Date:
On Tue, Jul 1, 2008 at 11:21 AM, Oliver Jowett <oliver@opencloud.com> wrote:
Chandra ASGI Tech wrote:

But I get the error
Exception in thread "main" java.lang.NoClassDefFoundError: postgreSQLTest

Your code isn't even running because the JVM can't find your main class. This isn't anything to do with JDBC, it's basic Java.

-O

HI, the error message seems so, but Java does work - i tested with a simple hello world program and it worked. So i do not think it is a problem with the JVM - but am not able to understand what the error is.
 

 

Re: JDBC driver not found error: Windows XP / JDK1.6.06 / PG8.2.9

From
tivvpgsqljdbc@gtech-ua.com
Date:
Chandra ASGI Tech написав(ла):
> On Tue, Jul 1, 2008 at 11:21 AM, Oliver Jowett <oliver@opencloud.com
> <mailto:oliver@opencloud.com>> wrote:
>
>     Chandra ASGI Tech wrote:
>
>         But I get the error
>         Exception in thread "main" java.lang.NoClassDefFoundError:
>         postgreSQLTest
>
>
>     Your code isn't even running because the JVM can't find your main
>     class. This isn't anything to do with JDBC, it's basic Java.
>
>     -O
>
>
> HI, the error message seems so, but Java does work - i tested with a
> simple hello world program and it worked. So i do not think it is a
> problem with the JVM - but am not able to understand what the error is.
>
I suppose you did not add "." to your classpath when specifying it. Try
without classpath to see if error change. Then ensure you've got correct
classpath.