Em đang code để kết nối vào SQL nhưng lỗi. Anh chị em sửa giúp em với ạ. Em cảm ơn
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package connecttosqlserver;
import com.microsoft.sqlserver.jdbc.SQLServerDataSource;
import java.sql.Connection;
import java.sql.SQLException;
import static java.time.Clock.system;
/**
*
* @author longc
*/
public class ConnectToSQLServer {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String server = "DESKTOP-1JO57N4\\SQL1";
String user;
user = "sa";
String password = "password";
String db = "master";
int port = 1433;
SQLServerDataSource ds = new SQLServerDataSource();
ds.setUser(user);
ds.setPassword(password);
ds.setDatabaseName(db);
ds.setServerName(server);
ds.setPortNumber(port);
try (Connection conn = ds.getConnection()) {
system.out.println("Ket noi voi SQl thanh cong");
system.out.println(conn.getCatalog());
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
Bị lỗi như thế này ạ
Error: Could not find or load main class connecttosqlserver.ConnectToSQLServer
C:\Users\longc\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)