http://xxg.javaeye.com/blog/174792
http://hi.baidu.com/feng2211/blog/item/009ceddb76858260d0164eb3.html
package cn.edu.nankai;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JDBCHelloWorld {
public static void main(String[] args) throws Exception {
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection conn = java.sql.DriverManager.getConnection(
"jdbc:derby://localhost:1527/Demo","classiccars", "classiccars");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select g.term_id, g.term from app.glossary g");
while(rs.next()) {
System.out.print(rs.getString("term_id") + "; "
+ rs.getString("term"));
System.out.println(" ");
}
rs.close();
stmt.close();
conn.close();
}
}
阅读(1634) | 评论(0) | 转发(0) |