Caused by: java.sql.SQLDataException: ORA-01840: 输入值对于日期格式不够长
atoracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)atoracle.jdbc.driver.T...
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) 展开
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) 展开
4个回答
展开全部
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)
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)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
找到你本地报错的代码,看看你的日期格式是否正确
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
加载数据库驱动怎么有错啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
贴代码 才能知道什么地方错的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询