このコードを実行して接続を確立しようとすると......このエラーが発生します
Apache-tomcat-7.0.8を使用しています
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());
}
%>