Getting Connected for the First Time
Posted by: Rob Pete
Date: May 16, 2005 06:43PM

Hello everyone. I am trying to make my first database connection to a mysql database with Java. I am using jdk 1.5.0, MySQL 4.1.11 nt, and I think I have the freshly downloaded driver C:\jdk1.5.0\jre\lib\ext\mysql-connector-java-3.0.16-ga-bin.jar" installed in the right spot. When I try to run the following code...

package dbfinder;

import java.sql.*;
import javax.sql.*;
import com.sun.rowset.JdbcRowSetImpl;
import javax.sql.rowset.JdbcRowSet;
import java.sql.ResultSetMetaData;

* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
public class DatabaseConnector {
public DatabaseConnector() {


public static void main(String args[]){
Connection connection;
Statement statement;
// ResultSet resultSet;
// ResultSetMetaData metaData;
String DATABASE_DRIVER = "com.mysql.jdbc.Driver";
String DATABASE_URL = "jdbc:mysql://localhost/state_crime";
String USER = "cis695d";
String PASSWORD = "cis695d";
JdbcRowSet rowSet = new JdbcRowSetImpl();
try {
Class.forName(DATABASE_DRIVER); // load database driver
System.out.println("class loaded");
rowSet.setCommand("Select * FROM state_crime_rates");

ResultSetMetaData metaData = rowSet.getMetaData();
int numberOfColumns;
numberOfColumns = metaData.getColumnCount();

} catch(SQLException sqlException){
catch(ClassNotFoundException classNotFound){


I get the following exception...

java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at com.sun.rowset.JdbcRowSetImpl.connect(
at com.sun.rowset.JdbcRowSetImpl.prepare(
at com.sun.rowset.JdbcRowSetImpl.execute(
at dbfinder.DatabaseConnector.main(

Does anyone have any ideas? Is it my code? Is there a different driver I should use? Any help would be greatly appreciated.

Options: ReplyQuote

Written By
Getting Connected for the First Time
May 16, 2005 06:43PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.