tenho uma duvida uso o sql server 2005 express , queria saber como faco pra instlar o drive dele no pc ? qual o melhor drive? e um exemplo pra eu testar conexao … aguardo ajuda para instalacao e configuracao do mesmo … achei esse exemplo na net.
[code]import java.sql.*;
public class ConnectionFactory {
private static final String url = “jdbc:microsoft:sqlserver://localhost:1433”;
private static final String driver = “com.microsoft.jdbc.sqlserver.SQLServerDriver”;
private static final String usuario = “”;
private static final String senha = “”;
public static Connection getConnection() throws SQLException {
try {
Class.forName(driver);
System.out.println("Conectando ao banco");
return DriverManager.getConnection(url, usuario, senha);
} catch (ClassNotFoundException e) {
throw new SQLException(e.getMessage());
} catch (SQLException e){
throw new SQLException(e.getMessage());
}
}
public static void main(String[] args) {
Connection conn = null;
try {
conn = ConnectionFactory.getConnection();
}
catch(Exception e) {
e.printStackTrace();
}
finally {
try {
if( conn != null ) conn.close();
}
catch(Exception e) {
e.printStackTrace();
}
}
}
}[/code]
mais quando rodo da isso:
java.sql.SQLException: com.microsoft.jdbc.sqlserver.SQLServerDriver
at ConnectionFactory.getConnection(ConnectionFactory.java:17)
at ConnectionFactory.main(ConnectionFactory.java:26)