当前位置: 代码迷 >> J2SE >> 求JAVA代码…增删改查SQL2000数据库!解决思路
  详细解决方案

求JAVA代码…增删改查SQL2000数据库!解决思路

热度:108   发布时间:2016-04-24 12:42:49.0
求JAVA代码……增删改查SQL2000数据库!
给个范例就行 ,做个简单的教育经历管理系统,就几张表

要简单的!越简单越好 
尤其修改删除

------解决方案--------------------
Java code
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; }}
------解决方案--------------------
更新用preparedStatement.update 你看下java基础吧
------解决方案--------------------
更新是这个preparedStatement.excuteupdate 2楼错了 不好意思
  相关解决方案