Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No Suitable Driver: getConnection

Status
Not open for further replies.

Bell1991

Programmer
Aug 20, 2003
386
US
Hi,

I am fairly new to JSP and i am trying to connect to a database (access) and i am getting the following error:

java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
.....

Here is my code - any suggestions would be great.

<%@page import= &quot;java.lang.*, java.io.*, java.util.*, java.sql.*, com.beans.Login&quot;%>

<jsp:useBean id=&quot;login&quot; class=&quot;com.beans.Login&quot; scope = &quot;session&quot; />
<jsp:setProperty name=&quot;login&quot; property=&quot;*&quot; />

<%=login.getUserName()%><%=login.getPassword()%>
<br>

<%
Driver drv = (Driver)
Class.forName(&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;).newInstance();
Connection con = java.sql.DriverManager.getConnection(&quot;jdbc:eek:dbc:Test2&quot;);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(&quot;Select * from Employee&quot;);

while ( rs.next() )
{
int eeType = rs.getInt(&quot;EmployeeType_ID&quot;);
int employeeID = rs.getInt(&quot;Employee_ID&quot;);


-- do what i need to do
}


Thanks in advance..
-Bell
 
Hi,

Once you have created the Driver object, you need to register the Dirver with DriverManager.

Ex:

Driver driver = (Driver)
Class.forName(&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;).newInstance();

DriverManager.registerDriver(driver);

After registring you can create the Connection Object

Connection con = DriverManager.getConnection(&quot;jdbc:eek:dbc:Test2&quot;);

Hope this helps you..

Cheers
-Venu


 
hi
your question is more general.
i offer you to use search for that type of question
it is better for you
you may get answer more frequently.
i use forums.java.sun.com near you can found a number of that kind of site
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top