insert语句jdbc

  String sql = "insert into a2008003jjhzgzb(a,b,c,d,e,f) values(?,?,?,?,?,?)";
  Connection conn = null;
  try {
   //装载驱动
   Class.forName("oracle.jdbc.driver.OracleDriver");
   //打开连接
   conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:class4","uswjx","uswjx");
   PreparedStatement pstm = conn.prepareStatement(sql);
   pstm.setString(1, uv.getTxt_userId());
   pstm.setString(2, uv.getTxt_userName());
   pstm.setString(3, uv.getTxt_userType());
   pstm.setString(4, uv.getTxt_passWord());
   pstm.setInt(5, uv.getAge());
   pstm.setInt(6, uv.hashCode());
   
   pstm.executeUpdate();
   pstm.close();
  } catch (Exception err) {
   err.printStackTrace();
  }
  

你可能感兴趣的:(java技术)