A
A
Alik_Kolizeev2021-01-08 13:31:49
PostgreSQL
Alik_Kolizeev, 2021-01-08 13:31:49

Can't fix error with jdbs Driver posgresql?

I just want to connect to postgresql but it gives an error
java.sql.SQLException: No suitable driver found for jdbs:postgresql://localhost:5432/postgres
here is the code

package com.company;

import java.sql.*;
public class Main{
    public static void main(String[] args){
        try{
            Connection conn=DriverManager.getConnection("jdbs:postgresql://localhost:5432/postgres","posgres","42661902");
            Statement st=conn.createStatement();
            ResultSet rs=st.executeQuery("select * from countries");
            while(rs.next()){
                System.out.println(rs.getString("contry_id")+", "+rs.getString("country_name"));

            }



        }
        catch (Exception e){
            System.out.print(e);
        }


    }
}

java version "1.8.0_271"
and here is the screen that the jar file is together with Main
5ff8348c85c0f150463579.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-01-08
@Alik_Kolizeev

jdb c :postgresql://..... ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question