Topic: 郁闷~~~为什么statement对象会为空???

  Print this page

1.郁闷~~~为什么statement对象会为空??? Copy to clipboard
Posted by: feiling
Posted on: 2006-01-01 13:31

各位仁兄,请指点一下愚弟!~!~我能连接上SQL,但是有时候执行statement对象是空的,有时候又没事~~~

2.Re:郁闷~~~为什么statement对象会为空??? [Re: feiling] Copy to clipboard
Posted by: why
Posted on: 2006-01-01 19:27

Show us your code, please.

3.Re:郁闷~~~为什么statement对象会为空??? [Re: feiling] Copy to clipboard
Posted by: feiling
Posted on: 2006-01-01 20:42

package dataConnect;
...............................
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
..............................
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:oo;DatabaseName=master","sa","");
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
}catch(Exception e){}

4.Re:郁闷~~~为什么statement对象会为空??? [Re: feiling] Copy to clipboard
Posted by: why
Posted on: 2006-01-01 23:01

Please don't just hide the exception, at least when debugging...
e.printStackTrace();

5.Re:郁闷~~~为什么statement对象会为空??? [Re: feiling] Copy to clipboard
Posted by: feiling
Posted on: 2006-01-02 14:28

原程序是有写的,不过根本没错,所以就没打印出来,现在发贴为了简便一点突出重点,所以就省了~~~~~

6.Re:郁闷~~~为什么statement对象会为空??? [Re: feiling] Copy to clipboard
Posted by: why
Posted on: 2006-01-02 20:47

I doubt createStatement would return null without throwing an Exception.
Please check whether createStatement statement is really executed.
(don't use debug mode, but use logging or print before and after the corresponding statements.)

7.Re:郁闷~~~为什么statement对象会为空??? [Re: feiling] Copy to clipboard
Posted by: feiling
Posted on: 2006-01-03 21:05

谢了!!
我确定Statement已经执行了,可能是我的编译器出了问题吧,在另一台机运行完全没事,而且之前在我机运行也没事.就是不知怎么回事~!~!~


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923