final String name=tf.getName();
char[] c=tf2.getPassword();
final String pass=new String(c);
final String age=tf5.getName();
final String sex=tf3.getName();
final String xueli=tf4.getName();
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "123456");
String sql="insert into user values(?,?,?,?,?)";
reparedStatement ps=con.prepareStatement(sql);
ps.setString(1, name);
ps.setString(2, pass);
ps.setString(3, age);
ps.setString(4, xueli);
ps.setString(5, sex);
ps.execute();
//ps.executeUpdate();
//ResultSet rs=ps.executeQuery();
rs.close();
}
catch(Exception e){
System.out.println("数据库没连上");
}
为什么我的添加不了 是应用程序
到ps.execute();这句程序就抛出异常了
急啊 在线等
char[] c=tf2.getPassword();
final String pass=new String(c);
final String age=tf5.getName();
final String sex=tf3.getName();
final String xueli=tf4.getName();
b1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "123456");
String sql="insert into user values(?,?,?,?,?)";
reparedStatement ps=con.prepareStatement(sql);
ps.setString(1, name);
ps.setString(2, pass);
ps.setString(3, age);
ps.setString(4, xueli);
ps.setString(5, sex);
ps.execute();
//ps.executeUpdate();
//ResultSet rs=ps.executeQuery();
rs.close();
}
catch(Exception e){
System.out.println("数据库没连上");
}
为什么我的添加不了 是应用程序
到ps.execute();这句程序就抛出异常了
急啊 在线等
解决方案 »
- java 多线程问题
- 服务器端使用java.nio:远程主机强迫关闭了一个现有的连接
- JComboBox 当有下拉框出来的时候,不响应键盘事件, 如何做?
- java 笔试题
- 菜鸟请叫了啦!!
- 这个问题如何实现?请帮忙写出代码?
- socket问题。万分紧急!!!我用socket把服务端的文件传到客户端上,但服务端总是提示找不到文件...
- 请教:为什么看不到调用命令行的执行结果呢?100分感谢~
- 一个关于JDBC的问题,用到SQL或Access 。一个初学者向各位师兄请教。
- 【JAVA入门】高手门帮忙看看printf()
- 学JAVA看些源码有用处吗?
- 一段代码中,只有一个知识点不明白,不用看完全代码,请进来看看~~~
把打印出来的信息贴出来
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.StatementImpl.checkForDml(StatementImpl.java:412)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1794)
at org.ct.cs.frame.MyFrame$6.actionPerformed(MyFrame.java:169)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.sql.SQLException: Column count doesn't match value count at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922)
at org.ct.cs.frame.MyFrame$6.actionPerformed(MyFrame.java:168)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
name pass age xueli sex
183362985
[email protected]