Well...I tried too many things..googled so many times..but still could not find solution to my problem.
I use windows 8 Enterprise Edition(if this has to do something with the problem)
Oracle 11.2.0
Apache Tomcat server 8.0
JDK 1.7
My oracle is installed in the D: drive and tomcat in c:. i copied the ojdbc6.jar file from oracle to lib directory of tomcat server.
Then i set CLASSPATH in environment variables as "C:\Program Files\Apache Software Foundation\Tomcat 8.0\lib\ojdbc6.jar" in system variables
My path variable is set as "C:\Program Files\Java\jdk1.7.0_02\bin".
My program is as follows in notepad:
<%@ page import="java.sql.*" %>
<html>
<body>
<%
Connection conn;
Statement st;
ResultSet rs;
try{
new oracle.jdbc.driver.OracleDriver();
String dbURL="jdbc:odbc:oracle:thin:@localhost:1521:XE";
String userId="system";
String pwd="moon";
conn=DriverManager.getConnection(dbURL,userId,pwd);
st=conn.createStatement();
rs= st.executeQuery("SELECT * FROM login");
while(rs.next())
{
System.out.println(rs.getString(1)+""+rs.getString(2));
}
}
catch(Exception e){}
%>
</body>
</html>
I get too many errors then
eroors |
---|
org.apache.jasper.JasperException: An exception occurred processing JSP page /page2.jsp at line 14 11: String userId="system"; 12: String pwd="moon"; 13: 14: conn=DriverManager.getConnection(dbURL,userId,pwd); 15: st=conn.createStatement(); 16: 17: rs= st.executeQuery("SELECT * FROM login"); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) root cause javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:905) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:834) org.apache.jsp.page2_jsp._jspService(page2_jsp.java:102) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) |
Nothing solved this problem.