Re: Java access pgsql sample

From: Yuva Chandolu <ychandolu(at)ebates(dot)com>
To: 'Ribamar FS' <ribafs(at)myrealbox(dot)com>
Cc: "'pgsql-jdbc(at)postgresql(dot)org'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Java access pgsql sample
Date: 2002-07-25 22:16:57
Message-ID: A0F24737FCB34F489EC955D143BDD8510173E0DB@exchange-sf1.corp.ebates.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

See the url carefully, ':' is missing after "postgresql" i.e before "//". It
should be

jdbc:postgresql://10.0.1.53:5432/javatest

Thanks
Yuva

-----Original Message-----
From: Ribamar FS [mailto:ribafs(at)myrealbox(dot)com]
Sent: Thursday, July 25, 2002 1:59 PM
To: Yuva Chandolu
Subject: Re: RE: RE: [JDBC] Java access pgsql sample

Really. After insert in classpath the error is now:

SQLException: driver not found: jdbc:postgresql//10.0.1.53:5432/javatest

Thank you again.

-----Original Message-----
From: Yuva Chandolu <ychandolu(at)ebates(dot)com>
To: 'Ribamar FS' <ribafs(at)myrealbox(dot)com>
Date: Thu, 25 Jul 2002 13:54:08 -0700
Subject: RE: RE: [JDBC] Java access pgsql sample

Hi,

Class org.postgresql.Driver is not found, so as Dave said, now it is your
classpath problem. See that pgjdbc2.jar is in classpath.

Thanks
Yuva

-----Original Message-----
From: Ribamar FS [mailto:ribafs(at)myrealbox(dot)com]
Sent: Thursday, July 25, 2002 1:25 PM
To: Yuva Chandolu
Subject: Re: RE: [JDBC] Java access pgsql sample

Atfer changes receive:

[root(at)boaviagem meus]# java SQLStatement
ClassNotFoundException: org/postgresql/Driver
SQLException: driver not found: jdbc:postgresql//localhost:5432/javatest

Thank you for your attention.

-----Original Message-----
From: Yuva Chandolu <ychandolu(at)ebates(dot)com>
To: 'Ribamar FS' <ribafs(at)myrealbox(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Date: Thu, 25 Jul 2002 12:24:52 -0700
Subject: RE: [JDBC] Java access pgsql sample

Hi,

Please check your jdbc url, it looks wrong to me. It should be in the form

jdbc:postgresql://<database server ip or hostname>:<database port>/<instance
name>

Eg. jdbc:postgresql://123.123.123.123:5432/javatest

Where 123.123.123.123 is the server on which you are running postgres
database and 5432 is it's default port, change port if you have specified a
diff one. javatest is the instance name in your case.

Thanks
Yuva

-----Original Message-----
From: Ribamar FS [mailto:ribafs(at)myrealbox(dot)com]
Sent: Thursday, July 25, 2002 12:11 PM
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [JDBC] Java access pgsql sample

Hi!

Help me with this sample. It don't work:

Linux Conectiva
Postgresql 7.2.1
pgjdbc2.jar

/etc/profile
JAVA_HOME="/usr/java/jsdk"
J2EE_HOME="/usr/java/j2ee"
CLASSPATH=".:$JAVA_HOME/lib:$J2EE_HOME/lib:/usr/java/jsdk/corejava/corejava.
zip"
J2EE_CLASSPATH=$CLASSPATH
PATH="$PATH:$JAVA_HOME/bin:$J2EE_HOME/bin"
export JAVA_HOME J2EE_HOME CLASSPATH J2EE_CLASSPATH

import java.sql.*;
public class SQLStatement {
public static void main(String args[]) {
String url = "jdbc:postgresql:javatest";
Connection con;
String query = "select col1 from test";
Statement stmt;
try {
Class.forName("org.postgresql.Driver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url,"postgres",
"postgres");

stmt = con.createStatement();


ResultSet rs = stmt.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int rowCount = 1;
while (rs.next()) {
System.out.println("Linha " + rowCount + ":
");
for (int i = 1; i <= numberOfColumns; i++) {
System.out.print(" Coluna " + i +
": ");
System.out.println(rs.getString(i));
}
System.out.println("");
rowCount++;
}
stmt.close();
con.close();

} catch(SQLException ex) {
System.err.print("SQLException: ");
System.err.println(ex.getMessage());
}
}
}

Errors:
ClassNotFoundException: org/postgresql/Driver
SQLException: driver not found: jdbc:postgresql:javatest

Thank you for attention. Sorry ny english (brasilian).

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

Browse pgsql-jdbc by date

  From Date Subject
Next Message basis volume limited 2002-07-26 00:52:07 howto connect OO to pgsql- with data-insertion access.
Previous Message Yuva Chandolu 2002-07-25 19:24:52 Re: Java access pgsql sample