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

1

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.