当前位置:Gxlcms > 数据库问题 > JDBC编程

JDBC编程

时间:2021-07-01 10:21:17 帮助过:3人阅读

简单地说,JDBC 可做三件事:与数据库建立连接、发送 SQL 语句并处理结果。下列代码段给出了以上三步的基本示例:

Connection con = DriverManager.getConnection("jdbc:odbc:wombat","login", "password");

Statement stmt =con.createStatement();

ResultSet rs =stmt.executeQuery("SELECT a, b, c FROM Table1");

while (rs.next()) {

int x = rs.getInt("a");

String s = rs.getString("b");

float f = rs.getFloat("c");

}

JDBC编程

标签:

人气教程排行