java 的一个问题???不懂哦,大家帮忙看看! you are using an invalid object, did you create an instance using "new"? show your code 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是你试图将一个值赋给不存在的变量是不是定义了数组什么的阿你而且数组没有定义长度?或者对数组进行了copy什么的 import java.sql.*;public class mytest{ public static void main(String[] args) { SearchType test = new SearchType(); System.out.println(test.mnumber); for(int i=0;i<test.mnumber;i++) System.out.println(test.mtype[i]); }}class SearchType{ String url = "jdbc:odbc:Question"; String sql; String qtype[],mtype[],atype[]; int qnumber,anumber; public SearchType() { try{ anumber = qnumber = 0; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connect = DriverManager.getConnection(url); Statement state = connect.createStatement(); ResultSet rs; sql = "SELECT AreaDescription FROM QuestionArea"; rs = state.executeQuery(sql); i = 0; while(rs.next()){ atype[i] = rs.getString(1); anumber++; i++; } sql = "SELECT QuestionTypeDescription FROM QuestionType"; rs = state.executeQuery(sql); i = 0; while(rs.next()){ qtype[i] = rs.getString(1); qnumber++; i++; } state.close(); connect.close(); } catch(ClassNotFoundException cnfe){ System.err.println(cnfe); } catch(SQLException sqle){ System.err.println(sqle.getMessage()); System.err.println(sqle.getSQLState()); System.err.println(sqle.getErrorCode()); } } } import java.sql.*;public class mytest{ public static void main(String[] args) { SearchType test = new SearchType(); System.out.println(test.mnumber); for(int i=0;i<test.mnumber;i++) System.out.println(test.mtype[i]); }}class SearchType{ String url = "jdbc:odbc:Question"; String sql; String qtype[],mtype[],atype[]; int qnumber,anumber; public SearchType() { try{ anumber = qnumber = 0; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connect = DriverManager.getConnection(url); Statement state = connect.createStatement(); ResultSet rs; sql = "SELECT AreaDescription FROM QuestionArea"; rs = state.executeQuery(sql); i = 0; while(rs.next()){ atype[i] = rs.getString(1); anumber++; i++; } sql = "SELECT QuestionTypeDescription FROM QuestionType"; rs = state.executeQuery(sql); i = 0; while(rs.next()){ qtype[i] = rs.getString(1); qnumber++; i++; } state.close(); connect.close(); } catch(ClassNotFoundException cnfe){ System.err.println(cnfe); } catch(SQLException sqle){ System.err.println(sqle.getMessage()); System.err.println(sqle.getSQLState()); System.err.println(sqle.getErrorCode()); } } } 你没有initialize atype[], qtype[] tryatype = new String[1000];qtype = new String[1000];before you run the sql query 在数组和ArrayList都能实现功能的情况下,优先选哪一个? Vista 下的 Netbeans 6.1 有乱码怎么版啊? 谁知道gmai和hotmaill邮箱的登陆 时候的的url ,在地址栏直接输入帐号密码就能登陆? 如何画一个上面2个角带圆弧的JButton? .war是什么文件格式,如何解压? 请问如何对filechooser中选择一个文件的事件进行设置处理 安装了mysql却无法运行java程序 我怎么运行不了java程序! 请教事件监听问题. 这段代码的执行结果不懂,有木有小伙伴帮忙看看啊! 关于JBuilder中使用JDK1.4的问题 我要学JAVA
是不是定义了数组什么的阿你
而且数组没有定义长度?
或者对数组进行了copy什么的
{
public static void main(String[] args)
{
SearchType test = new SearchType();
System.out.println(test.mnumber);
for(int i=0;i<test.mnumber;i++)
System.out.println(test.mtype[i]);
}
}
class SearchType
{
String url = "jdbc:odbc:Question";
String sql;
String qtype[],mtype[],atype[];
int qnumber,anumber;
public SearchType()
{
try{
anumber = qnumber = 0;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect = DriverManager.getConnection(url);
Statement state = connect.createStatement();
ResultSet rs;
sql = "SELECT AreaDescription FROM QuestionArea";
rs = state.executeQuery(sql);
i = 0;
while(rs.next()){
atype[i] = rs.getString(1);
anumber++;
i++;
}
sql = "SELECT QuestionTypeDescription FROM QuestionType";
rs = state.executeQuery(sql);
i = 0;
while(rs.next()){
qtype[i] = rs.getString(1);
qnumber++;
i++;
}
state.close();
connect.close();
}
catch(ClassNotFoundException cnfe){
System.err.println(cnfe);
}
catch(SQLException sqle){
System.err.println(sqle.getMessage());
System.err.println(sqle.getSQLState());
System.err.println(sqle.getErrorCode());
}
}
}
{
public static void main(String[] args)
{
SearchType test = new SearchType();
System.out.println(test.mnumber);
for(int i=0;i<test.mnumber;i++)
System.out.println(test.mtype[i]);
}
}
class SearchType
{
String url = "jdbc:odbc:Question";
String sql;
String qtype[],mtype[],atype[];
int qnumber,anumber;
public SearchType()
{
try{
anumber = qnumber = 0;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect = DriverManager.getConnection(url);
Statement state = connect.createStatement();
ResultSet rs;
sql = "SELECT AreaDescription FROM QuestionArea";
rs = state.executeQuery(sql);
i = 0;
while(rs.next()){
atype[i] = rs.getString(1);
anumber++;
i++;
}
sql = "SELECT QuestionTypeDescription FROM QuestionType";
rs = state.executeQuery(sql);
i = 0;
while(rs.next()){
qtype[i] = rs.getString(1);
qnumber++;
i++;
}
state.close();
connect.close();
}
catch(ClassNotFoundException cnfe){
System.err.println(cnfe);
}
catch(SQLException sqle){
System.err.println(sqle.getMessage());
System.err.println(sqle.getSQLState());
System.err.println(sqle.getErrorCode());
}
}
}
qtype = new String[1000];before you run the sql query