[Pgsql-ayuda] JDBC

From: hpl(at)colima(dot)com
To: pgsql-ayuda(at)tlali(dot)iztacala(dot)unam(dot)mx
Subject: [Pgsql-ayuda] JDBC
Date: 2003-01-02 09:06:26
Message-ID: 200301020906.DAA03499@glupsis.acsinet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Holap Lista !
Estoy empezando en postgres
Usando el siguiente programa de un manual de postgresql para probar el JDBC me
marca errores :-<
import java.io.*;
import java.sql.*;
public class myappjdbc
{
Connection conn;
Statement stmt;
String state_code;
public myappjdbc() throws ClassNotFoundException,
FileNotFoundException, IOException, SQLException
{
Class.forName("org.postgresql.Driver");
conn =
DriverManager.getConnection("jdbc:postgresql:prueba","usuario1","");
System.out.print("Enter a state code: ");
System.out.flush();
BufferedReader r = new BufferedReader(new
InputStreamReader(System.in));
state_code=r.readLine();
ResultSet res = stmt.executeQuery("SELECT sname FROM state
WHERE code = '" + state_code + "'");
if(res!=null)
while(res.next())
{
String state_name = res.getString(1);
System.out.println(state_name);
}
res.close();
stmt.close();
conn.close();
}
public static void main(String args[])
{
try
{
myappjdbc test = new myappjdbc();
}
catch (Exception exc)
{
System.err.println("Exception caught.\n"+exc);
exc.printStackTrace();
}
}
}
java myappjdbc
Enter a state code: AL
Exception caught.
java.lang.NullPointerException
java.lang.NullPointerException
at myappjdbc.<init>(myappjdbc.java:19)
at myappjdbc.main(myappjdbc.java:36)
Lo Probe en Postgresql 7.1 con RH 6.2 y Postgresql 7.2 con RH 7.3
Grapcias y Feliz Ao !

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message alejandro fernandez 2003-01-02 16:15:38 [Pgsql-ayuda] ayuda con SETOF
Previous Message hpl 2003-01-02 09:02:42 [Pgsql-ayuda] JDBC