Problem connecting oracle database to jsp pages using Apache Tomcat server 8.0

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.

>> Nothing solved this problem.
Can't fix a problem 'till an actual problem is identified.
>> ODBC Driver Manager ... Data source name not found
That appears to be ODBC drivers looking for a DSN (Data Set Name). If it wants a DSN, the DSN has to be specified in the code, and the DSN has to be configured in the windows host ODBC applet. So that is at least two squirrels to get in the right tree before moving forward. A ...host:...[port:]SID|service name are some of the bits needed in a jdbc connect string, and that is in no way related to DSNs. A Whole Different Animal. If it wants a DSN that might be what needs to go in the URL bit.
And ODBC setups can be confusing, especially if an x64 OS is in the mix- if that is the case there are two different ODBC configuration applets, one for x64 the other for x86, and if one gets as far as talking to an actual database it might toss an architecture error. Only way to fix that "problem" is *delete* the ODBC DSN and then run the correct (maybe the x86) ODBC config utility, and set up the DSN. Again.

Similar Messages

  • SetAttribute in JSP page and Apache tomcat server

    Hello all gurus: I have created a JSP using JDeveloper. It works fine within the web server installed with JDeveloper, but when I upload the application to apache tomocat server, it does not seem to work correctly.
    I am using setAttribute property of the session object, to save data. Listed below is a section of the code. Not sure if it is a cookie issue or what.
    <%
    int i_count = 0;
    if(session.getAttribute("create_user_first_time") == "") {
    session.setAttribute("create_user_first_time","FIRSTTIME");
    else {
    System.out.println("SECOND TIME DUDE.");
    System.out.println(request.getParameter("username").toString().trim());
    i_count = createuser (
    request.getParameter("username").toString().trim(),
    request.getParameter("password").toString().trim(),
    request.getParameter("Email").toString().trim(),
    request.getParameter("DOB").toString().trim(),
    request.getParameter("securityQ").toString().trim(),
    request.getParameter("securityA").toString().trim(),
    request.getParameter("Phone").toString().trim()
    System.out.println("after create user");
    System.out.println("i_count="+i_count);
    if (i_count == 3) {
    session.setAttribute("err_msg_create_user", "USER ALREADY EXISTS!");
    System.out.println("err_msg_create_user: USER ALREADY EXISTS!");
    else {
    session.setAttribute("err_msg_create_user", "Congratulations " + request.getParameter("username").toString().trim() + "!!Please proceed to login at the following URL: <a href=Login.jsp target='_blank'> Login </a>");
    System.out.println("CONGRATULATIONS!");
    %>

    Abder-Rahman wrote:
    I noticed the problem.The "Hello.jsp" file was still in "Notepad" format.Huh? What is it, the "Notepad" format?
    Do you mean that it is saved as hello.jsp.txt? Just rename the file then.
    It might be helpful to disable the setting "hide extensions for known file types" in the Windows Explorer options.

  • Not able to connect to database through JSP page

    Hello Everyone,
    I'm creating a simple JSP page (helloworld.jsp) that would get info from the db and display it but when I point my browser to http://localhost:8080/helloworld.jsp, I get ClassNotFound exception.
    <html>
    <head>
    <title>My first JSP page
    </title>
    </head>
    <body>
    <%@page import="java.sql.*" %>
    <%
         try{
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         String url = "jdbc:mysql:///" + "trylnp";
         String user = "root";
         String pass = "welcome";
         Connection conn = DriverManager.getConnection(url,user,pass); 
         out.println("here");
         if((conn != null)&&(!conn.isClosed()))
              out.println("Connected...");
         String releasenum="3.1.48A";
         String query = "Select * from releasedata where releaseno='" + releasenum + "'; ";
         Statement s = conn.createStatement();
         ResultSet rs = s.executeQuery(query);
         while(rs.next())
              String useraction = rs.getString("useraction");
              String releaseno = rs.getString("releaseno");
              int ninetyfivepercentile = rs.getInt("ninetyfivepercentile");
              int ninetypercentile = rs.getInt("ninetypercentile");
              int fiftypercentile = rs.getInt("fiftypercentile");
              out.println("useraction : ");
              out.println("releaseno : ");
              out.println("ninetyfivepercentile : ");
              out.println("ninetypercentile : ");
              out.println("fiftypercentile : ");                    
         catch(Exception e ){
              out.println(e);
    %>
    </body>
    </html> I've properly set my classpath to C:\Program Files\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jar
    and also put the jar file in all the WEB-INF sub folders inside C:\apache-tomcat-6.0.16\webapps (I know it had to go in one of the WEB-INF dir, but as I was not sure which one, I put the jar file in all of the WEB-INF folders)
    Please, do let me know if u know how to resolve the issue. It'll be a big help.
    Thanks.

    I've properly set my classpath to C:\Program Files\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jarI don't think that does anything. You aren't compiling a .java file.
    If you put mysql-connector-java-5.1.6-bin.jar in the directory:
    apache-tomcat-6.0.x/libit will be available to all your applications.
    After making a few changes to your code, the following worked for me:
    <html>
    <head>
    <title>My first JSP page</title>
    </head>
    <body>
    <%@page import="java.sql.*" %>
    <%
      try{
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      String url = "jdbc:mysql://localhost/mydb1";
      String user = "me";
      String pass = "jsptest";
      Connection conn = DriverManager.getConnection(url,user,pass);
      out.println("<div>here</div>");
      if((conn != null)&&(!conn.isClosed()))
        out.println("<div>Connected...</div>");
      String name="diane";
      String query = "Select * from mytable2 where name='" + name + "'" ; 
      Statement s = conn.createStatement();
      ResultSet rs = s.executeQuery(query);
      while(rs.next())
        //String useraction = rs.getString("useraction");
        //String releaseno = rs.getString("releaseno");
        //int ninetyfivepercentile = rs.getInt("ninetyfivepercentile");
        //int ninetypercentile = rs.getInt("ninetypercentile");
        //int fiftypercentile = rs.getInt("fiftypercentile");
        //out.println("useraction : ");
        //out.println("releaseno : ");
        //out.println("ninetyfivepercentile : ");
        //out.println("ninetypercentile : ");
        //out.println("fiftypercentile : ");       
        int id_result = rs.getInt("id");
        String name_result = rs.getString("name");
        out.println("<div>" + id_result + " - " + name_result + "</div>");
      catch(Exception e ){
        out.println("<div>something is wrong</div>");
        out.println("<div>" + e + "</div>");
    %>
    </body>
    </html>

  • PROBLEM connect oracle 9i with JBOSS 3.2.3  application server

    i want to connect my web app to oracle9i by jboss3.2.3 .
    The database is on server machine in my domain and the application is on my local machine.
    Please help me is urgent
    Thanks

    To configure JBoss with Oracle dataabse.
    1. Copy Oracle's JDBC driver .zip file /jdbc/lib/classes12.zip to the server/default/lib directory.
    2. Copy /docs/examples/jca/oracle-ds.xml , to /server/default/deploy dir.
    3. In the oracle-ds.xml file set the <driver-class/> and <connection-url/> settings
    Class: oracle.jdbc.driver.OracleDriver
    URL: jdbc:oracle:thin:@<host>:<port>:<database>
    In the Connection URL setting, <host> is the HOST value specified in the /network/ADMIN/tnsnames.ora file, and <port> is the PORT value specified in the tnsnames.ora file, and <database> is the database name.
    4.
    Modify the standardjbosscmp-jdbc.xml configuration file, setting the <datasource> and <datasource-mapping> elements to use Oracle:
    <jbosscmp-jdbc>
    <defaults>
    <datasource>java:/OracleDS</datasource>
    <datasource-mapping>Oracle9i</datasource-mapping>
    </defaults>
    </jbosscmp-jdbc>
    5.
    Modify login-config.xml to use Oracle. Add the following <application-policy> element to login-config.xml:
    <application-policy name = "OracleDbRealm">
    <authentication>
    <login-module code =
    "org.jboss.resource.security.ConfiguredIdentityLoginModule"
    flag = "required">
    <module-option name = "principal">sa</module-option>
    <module-option name = "userName">sa</module-option>
    <module-option name = "password"></module-option>
    <module-option name ="managedConnectionFactoryName">
    jboss.jca:service=LocalTxCM,name=OracleDS
    </module-option>
    </login-module>
    </authentication>
    </application-policy>
    5.

  • Are there any problems running oracle database express 10g and iis together

    Are there any problems running oracle database express 10g on an windows 2000 server or advanced server running iis 5?
    Does oracle database express cause any conflicts with iis (because of used ports etc)
    Could an server have running on it, both an website using iis and an oracle database express website without conflicts?

    I would not expect a problem under normal circumstances.
    Oracle's listener is set for a default port 1521 for database requests, port 8080 for HTMLDB requests. The database connections generally find an empty port above 1024 when establishing a connection.
    So, if IIS does not want to use 1521 or 8080, you will generally see no challenges. Even then it is fairly easy to move ORacle's port requirements elsewhere.
    Using port 8080 seems reasonably common, but that is easily changed - search for sethttpport in this forum. IIS tromping on 1521 would be rare as it has been a well known Oracle service port since, roughly, forever.

  • Suggest me the best practise for accesing database by JSP page

    Hi,
    Can you please suggest me the best practises to connect to database through JSP page.
    I am using the Struts-Portlet environment. And I have to display some contents from the database to the jsp page(view.jsp).
    Please suggest.
    Saurabh.

    If you know how to use struts and portlets, you wouldn't be asking this question. I suggest looking into the Model-View Controller pattern to get an idea how to set up a web application, then think about how to do it in a portlet environment.

  • Problem about using Oracle Form 6i to connect Oracle Database 10g express.

    Sorry to interrupt all of you.
    I have encountered a problem about using Oracle Form 6i to connect Oracle Database 10g express.
    As I would like to
    I use Oracle Net8 Easy Config to create a connection.
    According to "tnsnames.ora", the paramater of connection is as follows;
    XE =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA = (SID = XE))
    Unfortunately, when I use Oracle Net8 Easy Config to test the connection, an error message is prompted as follows:
    Connecting....
    The test did not succeed.
    ORA-03106: fatal two-task communication protocol error
    There may be an error in the fields entered
    or the server may not be ready for a connection.
    You can check the server and retry, or continue.
    After I google it, I still have no idea how to solve the problem. I would like to ask, could anyone mind providing some hints or solution to address the issues.
    Thanks for your assistance in advance.

    I don't believe the Net8 Easy Config (NEC) will create a compatible entry in the tnsnames.ora. I have Forms 6i running successfully against a 10g Express database, but I did not use the NEC - I created the entry myself. Here is the entry I use:
    XE=
      (DESCRIPTION=
        (ADDRESS=
          (PROTOCOL=TCP)
          (HOST=<<servername or IP address>>)
          (PORT=1521)
        (CONNECT_DATA=
          (SERVER=dedicated)
          (SERVICE_NAME=XE)
      )Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Connecting to a database in JSP but using connection in bean

    I have a bean which connects to a database which is as follows:
    package MyPackage;
    import java.sql.*;
    public class DataSourceBean{
            public DataSourceBean(){
         public void setDriver(String driver) throws ClassNotFoundException {
              Class.forName(driver);
         public void setUrl(String aUrl){
              url=aUrl;
         public void setUsername(String aUsername){
              username=aUsername;
         public void setPassword(String aPassword){
              password=aPassword;
         public static Connection getConnection() throws SQLException{
              return DriverManager.getConnection(url, username, password);
         private static String url;
         private static String username;
         private static String password;
    }I then connect to a database through my JSP page:
    <jsp:useBean id="db" class="MyPackage.DataSourceBean" scope="application">
       <jsp:setProperty name="db" property="driver" value="sun.jdbc.odbc.JdbcOdbcDriver" />
       <jsp:setProperty name="db" property="url" value="jdbc:odbc:MyDB" />
    </jsp:useBean>This opens the database for the session, but I then want to allow people to login using a seperate bean.
    My question is how do I use the connection created in the JSP page above in my login bean?
    I have also tried connecting to a database in my LoginBean by using:
    DataSourceBean dsb=new DataSourceBean();
    yet it doesn't recognise DataSourceBean for some reason.
    BTW my book suggests opening up the database using scope="application" but to me it seems that keeping the database open is risky, is it OK to keep the database open for the whole session? do you have any other suggestions for accessing the database through my DataSourceBean?
    Thanks for any help.

    hi shock,
    there are a number of considerations when it comes to the database connections.
    first of all is the database server yours or are you buying a hosting scheme?
    if the database server is yours then you may consider building a database connection pool and keeping it in a session parameter. there's no harm in that because connections are opened as needed and closed when not needed. you can specify the minimum and maximum number of connections and connectio keep-alive times.
    if you purchase your database from a host they possibly would object to having a db connection pool as connections are valuable for them. but in this case there is no harm to create a connection to the database per request because creating database connections are costly only for the database server. your application will not slow down that much.
    for performance check sites: www.crystaltours.com or www.seckinkonaklar.com
    in both sites all connections are created per request and the complete content (including menus and application properties) comes from the database.
    my suggestion is that if you are writing a commercial application that will be hosted in a server that is not yours then create a connection per request (no pooling here).
    i also would suggest to put your database access code in a single class -not in a bean- for easy maintenance, you can use that class in your beans.
    i hope this was your answer.
    cem.

  • How to connect Oracle database from Active Server page

    Hi
    This is srinivas aluri
    I have developed an application using ASP and MS-SQL7.
    Now i want to port this application to Oracle 8i database
    I have written my connection in seperate file called
    connection.inc using SQL OLEDB provider
    If i have to connect oracle database what will be my provider
    and what is the exact code for this connection string
    Here i am giving the code of SQL databse connection string
    strcon= Provider=SQLOLEDB.1;Persist Security Info=False;User
    ID=sa;Initial Catalog=prjdb;Data Source=servername
    i have tried by changing the provider name from SQLOLEDB.1 to
    OraOLEDB.oracle
    but i could not able connect the database.
    It is giving provider not found or not properly installed error.
    But the same code is perfectly working from Visual Basic code.

    it depends on configuration your going to choose, there are two ways--
    - Using X/Open standards, for this
    you have to make an entry of Resource manager in $TUXDIR/udataobj/RM file.
    Then in UBBConfig file in GROUPS section u have to set Openinfo.
    It also depend on which database you are going to use.
    In your service now you need to call tpopen() API from tpsvrinit() function.
    - Other possibility is, take an implicit connection using Pro*C or Pro*Cobol whatever platform you are using.
    EXEC SQL Connect ...

  • How to Connect Oracle Database without using TNS entry

    Hi,
    i need to connect Oracle Database server from my pc without using the TNS entry. How to do that?
    Regards,
    007

    You have marked the question as answered, so it means you can answer my questions:
    1.How do i check that i can make easy connect to the server or not, I mean is it configured on Server ?
    2.Can I make connection with easy connect without having Net Services software installed on the client ?
    3.What if I am not able to access sqlnet.ora ?
    4.Is there any difference in connect string, which is based upon OS for easy connect ?
    5.How do i use global database name, if it is configured ?
    6.What are pros and cons of using easy connect ?
    7....
    20....
    I think this are those 20 questions which John is talking about.
    Regards
    Girish Sharma

  • How to connect oracle database using jsf

    how to connect oracle database using javaserver faces with connection pooling

    Here is one way...
    http://jakarta.apache.org/commons/dbcp/

  • Insert data into table from JSP page using Entity Beans(EJB 3.0)

    I want to insert data into a database table from JSP page using Entity Beans(EJB 3.0).
    1. I have a table 'FRIENDS', (in Oracle 10g database).
    2. It has two columns, 'NAME' and 'CITY'. Both have datatype strings(varchar2).
    3. Now from a JSP page, having two textfields, 'NAME' and 'CITY', I want to insert data into table 'FRIENDS'.
    4. In between JSP and database is a Entity Bean(EJB 3.0) and a stateless session bean.
    5. I am using JDev as editor.
    Please provide me code ASAP or link with similar example.
    Thank you.
    Anurag

    Hi,
    I am also trying that scenario. So u can
    Post the jsp form data to a Servlet which will act as a Controller.
    In the servlet invoke the business method.
    Similar kind of app is in www.roseindia.net
    Hope this would help u.
    Meanwhile if u get any optimal solution, pls post it.
    Thanks,
    Happy Java Coding.

  • Hi guys Pls tell me a way to connect db4 database with jsp and which driver

    hi guys
    Pls tell me a way to connect db4 database with jsp and
    also tell me which driver i have to use
    also tell me how to connect with excel sheets

    take a look at the follwing links. There, you'll find all what you need :
    DB4:
    http://www.oracle.com/database/berkeley-db/je/index.html
    http://www.oracle.com/technology/products/berkeley-db/je/index.html
    http://www.oracle.com/database/berkeley-db/db/index.html
    http://www.oracle.com/database/docs/berkeley-db-je-datasheet.pdf
    Excel:
    http://64.18.163.122/rgagnon/javadetails/java-0516.html
    Hope That Helps

  • How to connect Oracle database into Visual basic 6.0

    Hi. I am using Oracle I Enterprise version 9.2.0.1, I have a problem for connecting oracle database into VB. I use a ODBC to connect oracle database with VB. By testing connection. Message tells me that "connection successfully", but I can not have a record display in VB. It tells me that can not publish a connection with ODBC. Please tell me why

    Are you using the Oracle ODBC driver? If so, which version?
    Are you writing your own VB application? What API are you using-- ADO? Can you post the code that's making a connection and the exact text of the error message?
    Justin

  • How to connect oracle database with JAVA

    how to connect oracle database with JAVA....
    using j2sdk and Jcreator . which connector to use .. what are the code for that ..

    PLEASE .... Ask in an Oracle Java forum.
    And read the documentaiton. There is a whole document devoted to doing that. http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/toc.htm has examples.
    PLEASE ... do not ask product questions in a forum which clearly has a title saying it is devoted to assisting with download problems.

Maybe you are looking for

  • What I think of itunes

    They make stylish products.. BUT!! there is quite obviousley a problem with the new upgraded itunes, (opening and connecting to the store).... most people are sitting around thinking "what next??".. what are we ment to do??... there are no actual ans

  • I am unable to create pdf using adobe printer to a redirected folder on a server running windows server 2003

    I am unable to create pdf using adobe printer to a redirected folder on a server running windows server 2003

  • Problems updating 80 GB Ipod

    I have been getting the following message each time I try to update my Ipod: error -54 [permErr: permissions error (on file open)] Can anyone help me fix this problem? The sceond problem is that when my Ipod has completed updating it states that ther

  • Calc optimization issue with commit blocks

    Hi there, How can we know the right commit block interval setting to the database? and though i am doing parallel calc its forcing to do the calc in serial mode due to some dependencies. Can anyone suggest me the best way to remove the dependencies!!

  • C++ Socket Programming

    Hi all, I am facing some problem in Socket programming(C++ & Solaris 5.0).I am using socket as basic connecting point & MEP(Message Exchange Protocol) as high level protocol to send & receive Message & ACK, between two different system. MEP is a prot