相关代码
classDriver=”sun.jdbc.odbc.JdbcOdbcDriver”
url=”jdbc:odbc:mysqlser2005”
举个例子
连接数据库查询表的相关语句:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:mysqlser2005","sa","sql");
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select * from userinfo");
while(rs.next())
{
out.print("
用户名:"+rs.getString("username")+"密码:"+rs.getString("password"));
}
rs.close();
stmt.close();
conn.close();