java 数据库的更新_更新了数据库[update ... set] java

我的java代码有问题 . 当我进行数据库更新但它们无法正常工作时 . 我使用了我在互联网上找到的三种方法,但仍然无法使用!请帮我提前谢谢你

package HLR_SERVEUR;

public class model_HLR{

public void setupdate(String[] information)

{

int imsdn_values,cins,kcs,kis;

long IMSI_values=0;

this.IMSI_values = Long.parseLong(information[0]);

this.imsdn_values = Integer.parseInt(information[1]);

this.kis = Integer.parseInt(information[2]);

this.kcs = Integer.parseInt(information[3]);

this.service = new String(information[4]);

this.nom = new String(information[5]);

this.prenom = new String(information[6]);

this.cins = Integer.parseInt(information[7]);

System.out.println(this.IMSI_values);

System.out.println(this.imsdn_values);

System.out.println(this.kis);

System.out.println(this.kcs);

System.out.println(this.service);

System.out.println(this.nom);

System.out.println(this.prenom);

System.out.println(this.cins);

try {

Class.forName("com.mysql.jdbc.Driver");

dbConnect = DriverManager.getConnection("jdbc:mysql://localhost/abonnes", "root","");

dbStatement = dbConnect.createStatement();

/*

test 1:

PreparedStatement prepareStatement = (PreparedStatement) dbConnect.prepareStatement("Update sim set ISMIDN="+this.imsdn_values +", KI="+this.kis +",KC="+this.kcs+",SERVICE='"+this.service +"',nom='"+this.nom +"',prenom='"+this.prenom +"',cin="+this.cins +" Where IMSI="+this.IMSI_value+"");

k=prepareStatement.executeUpdate();

test 2:

PreparedStatement checkDB = (PreparedStatement) dbConnect.prepareStatement( "UPDATE sim set ISMIDN= ? ,KI= ?,KC= ?,SERVICE= ?,nom= ?,prenom= ?,cin= ? Where ISMI= ? ");

checkDB.setInt(1,this.imsdn_values);

checkDB.setInt(2,this.kis);

checkDB.setInt(3,this.kcs);

checkDB.setString(4,this.service);

checkDB.setString(5,this.nom);

checkDB.setString(6,this.prenom);

checkDB.setInt(7,this.cins);

checkDB.setLong(8,this.IMSI_values);

k=checkDB.executeUpdate();

*/

/* test 3: */

dbStatement=dbConnect.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

ResultSet uprs = dbStatement

.executeQuery("SELECT * FROM sim where ISMI ='"

+ this.IMSI_values + "'");

uprs.moveToInsertRow();

uprs.updateInt("ISMIDN", this.imsdn_values);

uprs.updateInt("KI", this.kis);

uprs.updateInt("KC", this.kcs);

uprs.updateString("SERVICE", this.service);

uprs.updateString("nom", this.nom);

uprs.updateString("prenom", this.prenom);

uprs.updateInt("cin", this.cins);

uprs.insertRow();

uprs.beforeFirst();

dbStatement.close();

dbConnect.close();

} catch (SQLException ex) {

Logger.getLogger(View.class.getName()).log(Level.SEVERE, null, ex);

} catch (ClassNotFoundException ex) {

Logger.getLogger(View.class.getName()).log(Level.SEVERE, null, ex);

}

}

mari 12,2015 12:20:55 AM HLR_SERVEUR.model_HLR setupdate GRAVE:null com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:列'ISMI'在com.mysql.jdbc.SQLError.createSQLException不能为空(SQLError.java:931在com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)的com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java: 1715)位于com.mysql.jdbc.PreparedStatement.exe执行内部(PreparedStatement.java:1268)的com.mysql.jdbc.Connection.execSQL(Connection.java:3249)com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java) :1541)com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1455)at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1440)at com.mysql.jdbc.UpdatableResultSet.insertRow(UpdatableResultSet . java:739)at HLR_SERVEUR.model_HLR.setupdate(model_HLR.java:304)at HLR_SERVEUR.AbonnePanel_Rechercher.actionPerformed(AbonnePanel_Rechercher.jav) a:401)在javax.swing.AbstractButton.DefaultButtonModel.setPressed的javax.swing.AbstractButton $ Handler.actionPerformed(未知来源)javax.swing.DefaultButtonModel.fireActionPerformed(未知来源)的javax.swing.AbstractButton.fireActionPerformed(未知来源) (未知来源)位于java.awt.Component的javax.swing.JComponent.processMouseEvent(未知来源)的java.awt.Component.processMouseEvent(未知来源)的javax.swing.plaf.basic.BasicButtonListener.mouseReleased(未知来源) java.awt.Component上的java.awt.Container.ventEvent(未知来源)的java.awt.ComptainerEventImpl(未知来源) . java.awt.Component.dispatchEvent上java.awt.Container.dispatchEventImpl(未知来源)的.processEvent(未知来源) java.awt.Lightweight上的java.awt.LightweightDispatcher.processMouseEvent(未知来源)的java.awt.LightweightDispatcher.exetargetMventEvent(未知来源)上的(未知来源)java.awt.Container.dispatchEventImpl上的java.awt.LightweightDispatcher.dispatchEvent(未知来源)(未知来源)源码)在java.awt java.awt.Event上的java.awt.Component.dispatchEvent(未知来源)中的.Window.dispatchEventImpl(未知来源)java.awt上java.awt.EventQueue.access $ 500(未知来源)的java(未知来源) . java.security上的java.security.AccessController.doPrivileged(Native Method)java.security.Protevilege(未知来源)java.security上的EventQueue $ 3.run(未知来源)$ 1.doIntersectionPrivilege(未知来源) .ProtectionDomain $ 1.doIntersectionPrivilege(未知来源)java.awt.EventQueue $ 4.run(未知来源)java.awt.EventQueue $ 4.run(未知来源)java.security.AccessController.doPrivileged(Native Method)at java . java.awt上的java.awt.EventDispatchThread.pumpOneEventForFilters(未知来源)java.awt上java.awt.EventDispatchThread.pumpEventsForFilter(未知来源)的java.awt.EventQueue.dispatchEvent(未知来源)中的security.ProtectionDomain $ 1.doIntersectionPrivilege(未知来源) j的.EventDispatchThread.pumpEventsForHierarchy(未知来源) java.awt.EventDispatchThread.run上的java.awt.EventDispatchThread.pumpEvents(未知来源)中的ava.awt.EventDispatchThread.pumpEvents(未知来源)(未知来源)

mai 12,2015 1:42:15 AM HLR_SERVEUR.model_HLR setupdate GRAVE:null com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException:重复条目'216011100258963'for key'PRIMARY

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值