Sorry ,it's not clear(The JDBC of pgsql)

wxdqz

New Member
In fact ,i want to do some works about the postgresq and java, so i have to use JDBC,now i found i can't compile the prog
i have do some jobs:
1)export CLASSPATH=/usr/local/lib/jdbc7.0-1.1.jar
2)vi pg_hba.conf
and changed a line:
host all 192.168.0.0 255.255.255.0 trust
3)this is my prog,


import java.sql.*;

class firstdb
{
public static void main(String args[])
{


Connection dbcon=DriverManager.getConnection("jdbc:postgresql:Manage","dangdang","dangyadang");

Statement sta=dbcon.createStatement();
ResultSet rst=sta.executeQuery("select * from personcon");
while(rst.next()){
System.out.print("Column 1 returned");
System.out.println(rst.getString(1));
}
rst.close();
sta.close();
dbcon.close();
}
}

but i got the error:

firstdb.java:19: error:Exception "java.sql.SQLException" is not catched and does not appear in throws list [JLS 8.4.4]
i don't why,can somebody tell me?(My english is poor and i am a freshman),thanks sincerely!
 
Back
Top