當我嘗試運行此代碼建立連接......這個錯誤是使用Apache的Tomcat的7.0.8jsp的連接錯誤
org.apache.jasper.JasperException: Unable to compile class for JSP:
出錯未來
林在行:1 in the jsp file: /test_conn.jsp
連接不能被解析爲一個類型
1: <% Connection connection = null; try { // Load the JDBC driver String driverName = "oracle.jdbc.driver.OracleDriver"; Class.forName(driverName);
2:
3: // Create a connection to the database
4: String serverName = "URL";
代碼我已經試過:
<%@page import="java.sql.*,java.io.*,java.text.*,java.util.*" %>
<%@page import="java.util.*" %>
<%
Connection connection = null;
out.println("Before try");
try {
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
out.println("Entered try");
String url = "jdbc:oracle:thin:@:URL:port:sid";
String username = "usr";
String password = "pass";
connection = DriverManager.getConnection(url, username, password);
out.println("Successfully Connected");
}catch (SQLException e) {
out.println("Not Connected: "+ e.getMessage());
}
%>
請包括更多的代碼...像獲取驅動程序連接。 – mykey 2012-04-20 05:06:08