Purushottam
Purushottam

Reputation: 159

(JDBC-Rowset) java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/student_manage

this is my Java Program to display data from Table using JDBC Rowsetusing MySQL. Earlier it was running fine but don't know why it shows such an error. I have applied some solutions also but no improvement.

package question_3;

import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import javax.sql.rowset.JdbcRowSet;
import javax.sql.rowset.RowSetProvider;
public class JDBCRowset 
{
    public static void main(String[] args) throws Exception
    {
        
        try
        {
            JdbcRowSet rowSet = RowSetProvider.newFactory().createJdbcRowSet();
            String DATABASE_URL = "jdbc:mysql://localhost:3306/student_manage";
            String USERNAME = "root";
            String PASSWORD = "24121998";
            // specify JdbcRowSet properties
            rowSet.setUrl(DATABASE_URL);
            rowSet.setUsername(USERNAME);
            rowSet.setPassword(PASSWORD);
            rowSet.setCommand("SELECT * FROM authors"); // set query
            rowSet.execute(); // execute query
            
            // process query results
            ResultSetMetaData metaData = rowSet.getMetaData();
            int numberOfColumns = metaData.getColumnCount();
            System.out.printf("Authors Table : %n%n");
            
            for (int i = 1; i <= numberOfColumns; i++)
                System.out.printf("%-15s\t", metaData.getColumnName(i));
            System.out.println();
            
            // display each row
            while (rowSet.next())
             {
             for (int i = 1; i <= numberOfColumns; i++)
                  System.out.printf("%-15s\t",rowSet.getObject(i));
             System.out.println();
            }
        }
        catch (SQLException sqlException)
        {
           sqlException.printStackTrace();
           System.exit(1);
        }
    }
}

Don't Know why These errors are3 coming UP

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/student_manage at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228) at java.sql.rowset/com.sun.rowset.JdbcRowSetImpl.connect(JdbcRowSetImpl.java:643) at java.sql.rowset/com.sun.rowset.JdbcRowSetImpl.prepare(JdbcRowSetImpl.java:654) at java.sql.rowset/com.sun.rowset.JdbcRowSetImpl.execute(JdbcRowSetImpl.java:556) at question_3.JDBCRowset.main(JDBCRowset.java:23)

I have already added MySQL Connector in the reference section or classpath according to the latest MySQL Version, But it is not solved Yet

enter image description here

enter image description here

MySQL TABLE

enter image description here

Upvotes: 0

Views: 115

Answers (0)

Related Questions