jsp中如何用OracleDataSource连接数据库?
使用Eclipse + Myeclipse,在jsp页面中设置与oracle数据库的连接:
.....
<%@ page import = "java.sql.* " %>
<%@ page import = "oracle.jdbc.pool.* %>
<%@ page import = "oracle.jdbc.driver.* %>
<html>
<body>
<%
OracleDataSource ods = new OracleDataSource();
……
%>
……
</body>
</html>
访问该页面报错:OracleDataSource cannot be resolved to a type
页面中与数据库的连接代码可以在java类中编译运行,Myeclipse的Library sets中也引入了Oracle目录下的classes12.jar,CLASSPATH也包含了该jar包,在页首import oracle.jdbc.pool.时也有oracledatasource的提示,可是jsp中就是不能通过。
请问是设置的问题还是代码的问题呢?谢谢大家!
------解决方案--------------------String DBDriver = "oracle.jdbc.driver.OracleDriver ";
String DBLocation = "jdbc:oracle:thin:@172.16.58.160:1521:orc1 ";
String DBUser = "test ";
String DBPwd = "test ";
Class.forName(DBDriver);
Connection conn = DriverManager.getConnection(DBLocation, DBUser, DBPwd);
java.sql.Statement stmt = conn.createStatement();
ResultSet rs = null;