bitsCN.com
import java.sql.*;
public class testjdbc {
public static void main(string[] arges) throws sqlexception,classnotfoundexception{
string user="root";
string pwd="mysql";
//设定url
string myjdbc="jdbc:mysql://localhost:3306/test";
//加载mysql驱动
class.forname("com.mysql.jdbc.driver");
//创建连接会话
connection myconnection=drivermanager.getconnection(myjdbc,user,pwd);
//创建语句块对象
statement myoperation=myconnection.createstatement();
//获取结果集对象
resultset record=myoperation.executequery("select *from test");
while(record.next()){
//输出结果集对象
system.out.println(record.getint("id")+","+record.getstring("name"));
}
//关闭结果集
try{
if(record!=null)
//关闭结果集时需要处理异常
record.close();
}catch(exception e){
e.printstacktrace();
}finally{
try{
if(myconnection!=null)
myconnection.close();
}catch(exception e){
e.printstacktrace();
}
}
}
}
本文出自 “java技术社区” 博客
本版本全面兼容php5.6+,并且修复了许多官方程序的低级代码bug。在apache 2.4.17+php5.6.15环境下测试通过,人格保证无毒无木马,仅仅是一名ecshop热爱者心血来潮之作。ecshop编译更新日志:1、加入最新官方补丁。2、修改数据库连接底层为mysqli, 现在完美无缺了。3、再次对所有代码进行细节修复。4、adminers更新至1.1.2, 在线管理数据库的神器。5、测
0
bitsCN.com
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号