0

GOod day, I just learning java about 2 days from internet. Now, i'm trying to open connection with my database but i having a problem.

java.sql.SQLException: No suitable driver found for jdbc:sqlserver://192.168.0.222;user=sa;password=N4ughty123456

here is my script .

  private void kuybtnActionPerformed(java.awt.event.ActionEvent evt) {                                       
        String nameval = utext.getText();
        String passval = ptext.getText();
        String ipval   = iptext.getText();

        String dbURL = "jdbc:sqlserver://"+ipval+";user="+nameval+";password="+passval+"";
        Connection conn;
        try {
            conn = DriverManager.getConnection(dbURL);
        } catch (SQLException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (conn != null) {
            System.out.println("Connected");
        }
    }    

how can i fix this ? thanks in advance

Boby
  • 1,131
  • 3
  • 20
  • 52
  • [Microsoft JDBC Driver for SQL Server](https://learn.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server) – Elliott Frisch Jun 29 '17 at 04:11

1 Answers1

1

as already mentioned the jdbc driver has to be on the classpath, also don't forget to close that connection.. like Closing Database Connections in Java

André
  • 172
  • 13