Boa, nao estou conseguindo me conectar com o banco sql server , segue meu codigo de conexao. Grato!!
String Servidor = "LAPTOP-D381GI7F";
String serverport = "1433";
String dbName = "bdcontrole";
String usuario = "admin";
String password = "br010173";
String serverip="192.168.0.8";
Statement stmt = null;
ResultSet result = null;
String driver = com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url = "jdbc:sqlserver://"+Servidor+"\\SQLEXPRESS:"+serverport+";databaseName="+dbName+"";
try {
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, usuario, password);
stmt = conn.createStatement();
result = null;
String numos,desc;
result = stmt.executeQuery("select * from ordemservico");
while (result.next()) {
numos=result.getString("numos");
desc = result.getString("descricao");
System.out.println(numos+" "+desc);
}
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
vcs poderiam m ajuadar!!
grato