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
asked Jun 29, 2017 at 4:08
Boby
1,2084 gold badges26 silver badges56 bronze badges
-
Microsoft JDBC Driver for SQL ServerElliott Frisch– Elliott Frisch2017年06月29日 04:11:51 +00:00Commented Jun 29, 2017 at 4:11
1 Answer 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
default