String转换int的问题````
String sqlString2=null;
sqlString2=new String( "SELECT qtime FROM [asdfkk] where qUserID= '65465jk ' ");
Connection con2;
Statement sql2;
ResultSet rs2;
try{
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ");
}
catch(
ClassNotFoundException e2)
{
out.print( "类找不到! ");
}
try
{
con2=DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mnjie ", "sa ", "l13846554564dfgaad54564 ");
sql2=con2.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs2=sql2.executeQuery(sqlString2);
rs2.last();
rs2.beforeFirst();
while(rs2.next())
{
D2=rs2.getString( "qtime ");
}
con2.close();
}
catch(
SQLException e2)
{
out.print(e2.getMessage());
}
//out.print(D2);
String D4=D2;
int D3=Integer.parseInt(D4);
out.print(D3);
我这样导出值就会报错
exception
org.apache.jasper.JasperException: Exception in JSP: /message_question.jsp:147
144: }
145: //out.print(D2);
146: String D4=D2;
147: int D3=Integer.parseInt(D4);
148: out.print(D3);
149:
150: String sqlString=null;
如果我把
String D4=D2;
int D3=Integer.parseInt(D4);
out.print(D3);改成
String D4= "45544545456 ";
int D3=Integer.parseInt(D4);
out.print(D3);
就可以正常转换```不知道为什么 通过out.print(D2);也可以显出D2来说明D2有值
------解决方案--------------------首先你看一下D2里边的是什么啊.
------解决方案--------------------D2没有初始化,String D2=null