com.mysql.jdbc.sqlerror.createsqlexception_com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException...

如果运行主类,则会出现此错误:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insert into customerLogin(companyName,username,password) values('Big Company','D' at line 1

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)

at com.mysql.jdbc.Util.getInstance(Util.java:386)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4187)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4119)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815)

at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)

at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)

at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)

at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)

at dao.CustomerContactDAO.performUpdate(CustomerContactDAO.java:175)

at dao.DAOTemplate.executeUpdate(DAOTemplate.java:27)

at dao.CustomerContactDAO.addCustomerContact(CustomerContactDAO.java:88)

at test.Test.main(Test.java:29)

这是我的DAO中的代码。我认为错误在于这些代码行,但我不知道它是哪一行:

public boolean addCustomerContact(CustomerContact c) {

setQuery("insert into customerContact(companyName,lastName,firstName,email,telNum,local,cellNum) values(?,?,?,?,?,?,?);"

+ "insert into customerLogin(companyName,username,password) values(?,?,?)");

queries.add(getQuery());

KeyValuePair onePair;

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.STRING);

onePair.setValue(c.getCompanyName());

getParameters().add(onePair);

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.STRING);

onePair.setValue(c.getLastName());

getParameters().add(onePair);

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.STRING);

onePair.setValue(c.getFirstName());

getParameters().add(onePair);

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.STRING);

onePair.setValue(c.getEmail());

getParameters().add(onePair);

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.INT);

onePair.setValue(c.getTelNum() + "");

getParameters().add(onePair);

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.INT);

onePair.setValue(c.getLocal() + "");

getParameters().add(onePair);

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.STRING);

onePair.setValue(c.getCellNum() + "");

getParameters().add(onePair);

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.STRING);

onePair.setValue(c.getCompanyName());

getParameters().add(onePair);

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.STRING);

onePair.setValue(c.getUsername());

getParameters().add(onePair);

onePair = new KeyValuePair();

onePair.setKey(KeyValuePair.STRING);

onePair.setValue(c.getPassword());

getParameters().add(onePair);

return executeUpdate();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值