From: | "Ribamar FS" <ribafs(at)myrealbox(dot)com> |
---|---|
To: | ElielsonF(at)prodam(dot)sp(dot)gov(dot)br |
Cc: | pgsql-jdbc(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org, amatsushita(at)prodam(dot)sp(dot)gov(dot)br, claalmeida(at)prodam(dot)sp(dot)gov(dot)br, fsantos(at)prodam(dot)sp(dot)gov(dot)br, mjesus(at)prodam(dot)sp(dot)gov(dot)br, mrmoreira(at)prodam(dot)sp(dot)gov(dot)br, mantonio(at)prodam(dot)sp(dot)gov(dot)br, Marial(at)prodam(dot)sp(dot)gov(dot)br, ptupynamba(at)prodam(dot)sp(dot)gov(dot)br, tnunes(at)prodam(dot)sp(dot)gov(dot)br |
Subject: | Re: RES: [JDBC] Java access pgsql sample : Solution!!! |
Date: | 2002-07-26 14:15:55 |
Message-ID: | 1027692955.8b8a8ff9ribafs@myrealbox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-jdbc |
Hi (Olá) Elielson!
Thanks for all!
After last tips I move my db to other machine compile and execute fine.
Other libs in my machine?
I don't encounter.
Feedback to others:
jsdk1.4.1
PostgreSQL 7.2
My /etc/profile:
=========================
JAVA_HOME="/usr/java/jsdk"
J2EE_HOME="/usr/java/j2ee"
CLASSPATH=.:$JAVA_HOME/jre/lib/ext/pgjdbc2.jar:$JAVA_HOME/lib:$JAVA_HOME/jre/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
My sample:
=========================
import java.sql.*;
public class SQLStatement {
public static void main(String args[]) {
String url = "jdbc:postgresql://10.0.1.53:5432/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("select col1 from test");
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());
}
}
}
==========================
Thank you, thank you very mutch!
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Sullivan | 2002-07-26 14:22:28 | Re: Evolving databases (eg deleting columns) |
Previous Message | Marc G. Fournier | 2002-07-26 14:13:01 | Re: Bad HTML in Mail List Archives |
From | Date | Subject | |
---|---|---|---|
Next Message | Chantal Ackermann | 2002-07-26 14:30:24 | Re: PreparedStatement: setting column names dynamically |
Previous Message | Dave Cramer | 2002-07-26 14:07:01 | Re: Problem with JDBCRealm in Tomcat |