0

I have Deployed jar file of postgres current version in eclipse (web-inf/lib) foleder but still Class.forName not laoded`, when I open perspective with same settings then it is connected open Perspectice image,please view on clicking it

    Connection connect() throws SQLException,ClassNotFoundException {
    System.out.println("welcome to the world of database");
    Connection conn = null;

     try {
        Class.forName("org.postgresql.Driver");
        System.out.println("class loaded");
     }catch(ClassNotFoundException e){
         System.out.println("class not loaded");

     }
     conn=DriverManager.getConnection("jdbc:postgresql://localhost:2345/my_first_databse", "postgres","postgres");
        System.out.println("Connected to the PostgreSQL server successfully.");
        return conn;

}//eof connect

output: welcome to the world of database class not loaded No suitable driver found for jdbc:postgresql://localhost:2345/my_first_databse

  • The code as shown will not produce a 'no suitable driver found' error. At most it would produce a `ClassNotFoundException` if the driver is not on the classpath. Your problem is elsewhere (eg specifying an incorrect JDBC url). – Mark Rotteveel Mar 31 '20 at 12:34
  • @MarkRotteveel Dear sir, I have opened database management perspective with same url,and user password it worked fine for me, I have Added Image of that in Question Pleasesee that image,I think You can help me – Santosh Chouhan Mar 31 '20 at 13:35
  • Your screenshot is irrelevant to the problem at end. Please provide a [mre] and make sure to include the full stacktrace. In any case, the code as shown will **never** produce a 'no suitable driver found' error, so the problem will be elsewhere in your code. That said, the duplicate I linked covers most cases. – Mark Rotteveel Mar 31 '20 at 13:41
  • I have Added more code for better understanding... – Santosh Chouhan Mar 31 '20 at 13:56

0 Answers0