java 数据库连接的几个步骤
时间:2021-07-01 10:21:17
帮助过:2人阅读
= "jdbc:oracle:thin:@你的主机ip :1521:orcl";
// 设置连接字符串
String username = "你的用户名"
;
String password = "你的密码"
;
Connection con=
java.sql.DriverManager.getConnection(url,user,password);
Statement stmt =
con.createStatement();
StringBuffer sql =
new StringBuffer("insert into user values (" + list.get(1).getId()+", "+list.get(1).getUserName()+", "+list.get(1).getPassword()+")"
);
for(
int i = 2; i < list.size(); i++
){
sql.append(", ("+ list.get(i).getId()+", "+list.get(i).getUserName()+", "+list.get(i).getPassword()+")");
//
}
sql.append(";"
);
ResultSet rs =
stmt.executeQuery(sql);
rs.close();
stmt.close();
con.close();
java 数据库连接的几个步骤
标签: