variable con might not have been initialized
来源:学生作业帮 编辑:搜搜做题作业网作业帮 分类:综合作业 时间:2024/04/28 10:49:56
variable con might not have been initialized
什么错误啊?
我已经初始化了啊,
Connection con=null;
con=DriverManager.getConnection("jdbc:odbc:sun","","");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
为什么它还是说没有呢
什么错误啊?
我已经初始化了啊,
Connection con=null;
con=DriverManager.getConnection("jdbc:odbc:sun","","");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
为什么它还是说没有呢
英文提示的意思是变量con没有被初始化,你应该在申明之后马上把它初始化吧.下面是一个jsp连接oracle数据库的代码,我以前做项目时照着一本书一个一个字母敲下来的,应该没有错误吧,
package firm;
import java.sql.*;
public class firm
{
String sDBDrive ="sun.jdbc.odbc.JdbcOdbcDrive";
String sConnStr="jdbc:odbc:firm";
private Connection conn=null;
private Statement stmt=null;
ResultSet rs=null;
public firm()
{
try
{
Class.forName(sDBDrive);
}
catch (java.lang.ClassNotFoundException e)
{
System.err.println("virtual_1():"+e.getMessage());
}
}
public ResultSet executeQuery(String sql)
{
rs=null;
try
{
Connection conn=DriverManager.getConnection("jdbc:odbc:firm","echo1004","echo1004shma");
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex)
{
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return rs;
}
public void executeUpdate(String sql)
{
stmt=null;
rs=null;
try
{
Connection conn=DriverManager.getConnection("jdbc:odbc:firm","echo1004","echo1004shma");
stmt=conn.createStatement();
stmt.executeQuery(sql);
stmt.close();
conn.close();
}
catch (SQLException ex)
{
System.err.println("aq.executeQuery:"+ex.getMessage());
}
}
public void closeStmt()
{
try
{
stmt.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
public void closeConn()
{
try
{
conn.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
package firm;
import java.sql.*;
public class firm
{
String sDBDrive ="sun.jdbc.odbc.JdbcOdbcDrive";
String sConnStr="jdbc:odbc:firm";
private Connection conn=null;
private Statement stmt=null;
ResultSet rs=null;
public firm()
{
try
{
Class.forName(sDBDrive);
}
catch (java.lang.ClassNotFoundException e)
{
System.err.println("virtual_1():"+e.getMessage());
}
}
public ResultSet executeQuery(String sql)
{
rs=null;
try
{
Connection conn=DriverManager.getConnection("jdbc:odbc:firm","echo1004","echo1004shma");
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
}
catch(SQLException ex)
{
System.err.println("aq.executeQuery:"+ex.getMessage());
}
return rs;
}
public void executeUpdate(String sql)
{
stmt=null;
rs=null;
try
{
Connection conn=DriverManager.getConnection("jdbc:odbc:firm","echo1004","echo1004shma");
stmt=conn.createStatement();
stmt.executeQuery(sql);
stmt.close();
conn.close();
}
catch (SQLException ex)
{
System.err.println("aq.executeQuery:"+ex.getMessage());
}
}
public void closeStmt()
{
try
{
stmt.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
public void closeConn()
{
try
{
conn.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
variable con might not have been initialized
delphi 提示variable "form2"might not have been initialized.
java新人求解决"variable season might not have been initialized"
local variable 'n' used without having been initialized
local variable 'S' used without having been initialized
local variable 'x' used without having been initialized是什么意思
local variable 'd' used without having been initialized是什么意思
Hardware changes might not have been detected
eclipse中,“The local variable XXX may not have been initializ
英语翻译I might have been skeptical had I not been used to respo
英语翻译Matters that have not been provided herewith will be con
not initialized是什么意思