?? test.java
字號(hào):
package untitled1;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */import java.util.*;import java.io.*;import java.sql.*;public class test { public test() { } public static void main(String[] args) { test test1 = new test(); Connection conn = null; // PreparedStatement stmt = null; Statement stmt = null; ResultSet rs = null; String driver = "org.postgresql.Driver"; String url = "jdbc:postgresql://localhost:5432/order"; String user = "wymna"; String passwd = ""; String select = "select id,name from grest "; int Id; String Name; String address; try { Class.forName(driver); conn = DriverManager.getConnection(url, user, passwd); if (conn!=null ) { System.out.println("dsdgg"); } stmt = conn.createStatement(); rs = stmt.executeQuery(select); while (rs.next()) { Id = rs.getInt(1); Name = rs.getString( "name"); //address =rs.getString("address"); System.out.println(Name+" "); // System.out.println(address+" "); } } catch (Exception e) { e.printStackTrace(); } finally { try { // Always close properly if (rs != null) { rs.close(); } if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { e.printStackTrace(); } } }}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -