求JAVA代码……增删改查SQL2000数据库!

czs479 2009-01-11 06:28:11
给个范例就行 ,做个简单的教育经历管理系统,就几张表

要简单的!越简单越好
尤其修改删除
...全文
191 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
GkfSyser 2009-01-11
  • 打赏
  • 举报
回复
更新是这个preparedStatement.excuteupdate 2楼错了 不好意思
timbear 2009-01-11
  • 打赏
  • 举报
回复
一楼的代码够用了~~
lihan6415151528 2009-01-11
  • 打赏
  • 举报
回复
路过,关注
GkfSyser 2009-01-11
  • 打赏
  • 举报
回复
这种基础问题先百度下再问
GkfSyser 2009-01-11
  • 打赏
  • 举报
回复
更新用preparedStatement.update 你看下java基础吧
GkfSyser 2009-01-11
  • 打赏
  • 举报
回复

public class UserSystem {
public static void main(String args[]){
UserSystemDAO UserSystemDAO=new UserSystemDAO();
}
}



import java.sql.*;
public class UserSystemDAO {

String insertSql="insert into table_usersystem_dictionary values(?,?,?,?)";

UserSystemDAO(){
executeSQL();
}
private void executeSQL(){
UserSystemDB userSystemDB=new UserSystemDB();

PreparedStatement preparedStatement=null;

Connection connection=userSystemDB.createConnection();

try{
preparedStatement=connection.prepareStatement(insertSql);
preparedStatement.setString(1, "95002");
preparedStatement.setString(2,"user");
preparedStatement.setString(3,"shl");
preparedStatement.setString(4,"001");
preparedStatement.addBatch();
preparedStatement.executeBatch();
preparedStatement.close();
System.out.println("Insert success");
}
catch(Exception e){e.printStackTrace();}
finally{
try{
connection.close();
}
catch(Exception e){e.printStackTrace();}
}
}
}



import java.sql.Connection;
import java.sql.DriverManager;
public class UserSystemDB {

public Connection createConnection(){
Connection connection=null;
try{

Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
//String url="jdbc:odbc:argon";
String url="jdbc:microsoft:sqlserver://Localhost:1433;DatabaseName=user";
connection=DriverManager.getConnection(url,"sa","");
System.out.println("JDBC-ODBC的驱动程序注册成功");

}
catch(Exception e){
e.printStackTrace();
System.out.println("找不到驱动程序");
}
return connection;
}
}

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧