import java.sql.*;
public class Untitled1 {
public Untitled1() {
}
public void test() {
try {
String url = "jdbc:postgresql://localhost/mydb";
String user = "Administrator";
String password = "000000";
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery(" select city from weather ");
System.out.println("결과 ==>> ");
if(!rset.next()) {
System.out.println("Nothing!");
} else {
String show = rset.getString(1);
System.out.println("->> "+show);
}
if(rset != null) rset.close();
if(stmt != null) stmt.close();
if(con != null) con.close();
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
public static void main(String[] args) throws Exception {
Untitled1 untitled11 = new Untitled1();
untitled11.test();
}
}