public class Contion{
Contion(){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e){}
}
Connection getCon() throws SQLException{
Connection Ex1Con = DriverManager.getConnection("jdbc:odbc:book", "",
"");
return Ex1Con;
}}请问能不能使用构造方法直接返回Connection呢?怎么做?
Contion(){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e){}
}
Connection getCon() throws SQLException{
Connection Ex1Con = DriverManager.getConnection("jdbc:odbc:book", "",
"");
return Ex1Con;
}}请问能不能使用构造方法直接返回Connection呢?怎么做?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货