为什么找不到getConnection()方法
我写数据库连接池为什么eclipse提示说找不道getConnection()方法?importjavax.activation.DataSource;importjav...
我写数据库连接池 为什么eclipse提示说找不道getConnection()方法?
import javax.activation.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.sql.Connection;
public class xing {
public Connection poolConnect(){
Connection ds=null;
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
ds = (Connection) envCtx.lookup("jdbc/photo");
Connection conn = ds.getConnection();
}catch (Exception e) {
System.err.println("poolConnect:"+". " + e.getMessage());
}
}
} 展开
import javax.activation.DataSource;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.sql.Connection;
public class xing {
public Connection poolConnect(){
Connection ds=null;
try {
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
ds = (Connection) envCtx.lookup("jdbc/photo");
Connection conn = ds.getConnection();
}catch (Exception e) {
System.err.println("poolConnect:"+". " + e.getMessage());
}
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询