Hi, I made a JSP and i need to connect to an oracle database. I am using Tomcat and i know that i need to include the JDBC driver in the lib directory. I have taken the classes12.zip to oracle/jdbc/lib directory and unziped it in the tomcat lib directory. Here is the Error: SQLException: No suitable driver Can somebody help me resolve this problem??? Thank you.. Jeff
When do you get the Exception? When you call insertSomething()? Have you called connect() first? (Did you notice you are instantiating the connection object in insertSomething()?) If you have already called connect() and then call insertSomething() and are getting this message back, then I'm not positive, but it sounds like you might be loading the wrong driver for your data source.
Joined: Jun 14, 2001
This is my jsp file <html> <head> <title>Insert something into a database</title> </head> <body>
<h1>Here is the JSP</h1>
<jsp:useBean id="insert" class="JspInsert.DataBaseInsert" scope="request"> <jsp:setProperty name="insert" property="something" value="something already in the bean" /> </jsp:useBean> <% out.print(insert.connect()); %>
<% insert.setSomething("a new something to insert"); %>
The way the DriverManager works, from what I remember, is you register x number of drivers with it. In your case x=1, and the driver is oracle.jdbc.driver.OracleDriver. If the class.forName were failing, i.e. the OracleDriver wasn't being found in your classpath, you'd get a different exception. So I assume the oracle driver got loaded into the DriverManager. The next step is at Connection creation time. You provide a URL for your connection, and basically the DriverManager runs through all the drivers that have registered with it and asks each one in turn if it can handle this URL. The first one that can responds with a usable Connection. If none of them like the URL, it falls through and you get a "No suitable driver" message. So the short answer is that there is something wrong with your URL. I don't know all the ways you can form an Oracle URL, and your post has some smiley in the middle of it, so I can't say what the exact problem is in the URL, but it's the URL. Read the Oracle docs if you cannot tweak it yourself.
Joined: Jan 19, 2001
I think he is right, you need to tweak something in these lines: