为了账号安全,请及时绑定邮箱和手机立即绑定

输入值对于日期格式不够长是什么情况?

输入值对于日期格式不够长是什么情况?

HUX布斯 2022-04-21 15:11:14
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:861)at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1145)at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1267)at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3493)at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
查看完整描述

2 回答

?
泛舟湖上清波郎朗

TA贡献1818条经验 获得超3个赞

public class test1 extends JFrame implements ActionListener{
JPanel jp1,jp2;
JTable jt1=null;
JLabel jl1=null;
JTextField jtf=null;
JButton jb1,jb2,jb3,jb4;
JTable jt=null;
JScrollPane jsp=null;
//String sql;
public static void main(String[] args) {
test1 t1=new test1();
}
test1(){
jp1=new JPanel();
jl1=new JLabel("请输入要查询的编号");
jtf=new JTextField(10);
jb1=new JButton("查询");

jb1.addActionListener(this);
jp1.add(jl1);
jp1.add(jtf);
jp1.add(jb1);

jp2=new JPanel();
jb2=new JButton("添加");
jb3=new JButton("删除");
jb4=new JButton("修改");
jp2.add(jb2);
jp2.add(jb3);
jp2.add(jb4);
tablemodel t=new tablemodel();

jt1=new JTable(t);
jsp=new JScrollPane(jt1);
this.add(jsp);
this.add(jp1,"North");
this.add(jp2,"South");

this.setSize(400,400);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);

}
public void actionPerformed(ActionEvent arg0) {
if(arg0.getSource()==jb1){

//System.out.println("王博古");

String name=this.jtf.getText().trim();
String sql="select * from lixianqi where name="+"'"+name+"'";
tablemodel t=new tablemodel(sql);
jt.setModel(t);
}
}
}

Vector rowData, columnNames;
Connection connection=null;
PreparedStatement ps=null;
ResultSet res=null;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public tablemodel(){

columnNames=new Vector();
columnNames.add("编码");
columnNames.add("版本");
columnNames.add("名字");
rowData=new Vector();
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
connection=DriverManager.getConnection
("jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=zhudan","sa","zhudan");
ps=connection.prepareStatement("select * from lixianqi");
res=ps.executeQuery();

while(res.next()){
Vector v=new Vector();
v.add(res.getInt(1));
v.add(res.getString(2));
v.add(res.getString(3));
rowData.add(v);
}

}catch(Exception e){
e.printStackTrace();

}finally{

try {
if(res!=null)res.close();
if(ps!=null)ps.close();
if(connection!=null)connection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}
}

};
public tablemodel(String sql){

columnNames=new Vector();
columnNames.add("编码");
columnNames.add("版本");
columnNames.add("名字");
rowData=new Vector();
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
connection=DriverManager.getConnection
("jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=zhudan","sa","zhudan");
ps=connection.prepareStatement(sql);
res=ps.executeQuery();

while(res.next()){
Vector ve=new Vector();
ve.add(res.getInt(1));
ve.add(res.getString(2));
ve.add(res.getString(3));
rowData.add(ve);
}

}catch(Exception e){
e.printStackTrace();

}finally{

try {
if(res!=null)res.close();
if(ps!=null)ps.close();
if(connection!=null)connection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}
}
}

//得到多少列
public int getColumnCount() {
System.out.println("a");
return this.columnNames.size();
}
//得到多少列
public int getRowCount() {
System.out.println("2");
return this.rowData.size();
}
//得到哪行哪列
public Object getValueAt(int row, int colum) {
System.out.println("3");
return ((Vector)this.rowData.get(row)).get(colum);
}

public String getColumnName(int column) {
// TODO Auto-generated method stub
return (String) columnNames.get(column);
}

}

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at chack.test1.actionPerformed(test1.java:75)



查看完整回答
反对 回复 2022-04-24
?
慕工程0101907

TA贡献1887条经验 获得超5个赞

找到你本地报错的代码,看看你的日期格式是否正确

查看完整回答
反对 回复 2022-04-24
  • 2 回答
  • 0 关注
  • 266 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信