JDBC

xiaoxiao2021-02-28  87

更换数据库,应用程序跨平台 两个问题的解决——JDBC

JDBC——JDBC标准API(java.sql,javax.sql),JDBC驱动程序

======================================================

要取得数据库联机: 注册Driver操作对象 取得Connection操作对象 关闭Connection操作对象

Class.forName(“com.mysql.jdbc.Driver”);

Connection conn = DriverManager.getConnection(jdbcUrl,username,password);

======================================================= Statement stmt = conn.createStatement();

int i = stmt.executeUpdate(“INSERT INTO t_message VALUES(1,’justin’,”+“‘justin@mail.com’,’message…’)”);

ResultSet result = stmt.executeQuery(“SELECT * FROM t_message”); result.getString(“name”),result.getInt(“id”)

stmt.execute(sql) ResultSet rs = stmt.getResultSet(); int updated = stmt.getUpdateCount();

转载请注明原文地址: https://www.6miu.com/read-46679.html

最新回复(0)