Statement st=con.createStatement();
String sql1="select * from user";
ResultSet rs=st.executeQuery(sql1);
while(rs.next()){
int id=rs.getInt(1);
String name1=rs.getString(2);
String pass=rs.getString(3);
int age1=rs.getInt(4);
String sex1=rs.getString(5);
java.util.Date d=rs.getDate(6);
System.out.println(id+":"+name1+":"+pass+":"+age1+":"+sex1+":"+d);
}
con.close();
}
}
Exception in thread "main" com.mysql.jdbc.MysqlDataTruncation: Data truncation: Data too long for column 'sex' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4118)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)
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 mysql.Test.main(Test.java:27) 作者: 江大海 时间: 2013-5-22 22:09
我了个去,想帮你解决的,但是看到这些代码我就吓尿了,太多啦,又还没用到elic什么工具来着
帮你顶一个 作者: SOAR 时间: 2013-5-22 22:13
Data too long for column 'sex' at row 1
数据太长了啊。你的表中sex的字段设置的太短了。作者: 谢孔营 时间: 2013-5-22 22:33
package mysql;
import java.sql.*;
import java.text.SimpleDateFormat;