No suitable driver found for jdbc oracle thin

Posted by Somesh Shinde On Tuesday, 26 July 2016 0 comments

No suitable driver found for jdbc oracle thin


I run this program And I got Error which shows in cmd..


import java.sql.*;

class Database
{
 public static void main(String arg[])
    {

     try
       {
String url="jdbc:orcl:thin:@localhost:1521:orcl";   
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(url,"scott","tiger");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from aj1");

while(rs.next())
     {
    System.out.println("\n"+rs.getInt(1)+"  "+rs.getString(2));
      }
    }
catch(Exception e){e.printStackTrace();}
}
}
Kindly give the solution for this:
enter image description here
Solution for above Error is::
You url String must be
String url="jdbc:oracle:thin:@localhost:1521:orcl";
instead of
String url="jdbc:orcl:thin:@localhost:1521:orcl";
and try.

0 comments:

Post a Comment