Como colocar parâmetros no DriverManager.getConnection?
Servidor: PARTICUL-791FFA
Banco de Dados: dbpe01.dbo.tbpe01
User name: PARTICUL-791FFA\helena
Login: não tem
Senha: não tem
Connectioncon=DriverManager.getConnection("jdbc:jtds:sqlserver://PARTICUL-791FFA/dbpe01.dbo.tbpe01","","");Statementstmt=con.createStatement();ResultSetrs=stmt.executeQuery("SELECT a, b, c FROM Table1");
// if (rs.next()) {while(rs.next()){System.out.println(“Imprimelinhas!!!”);}}catch(Exceptionex){ex.printStackTrace();}finally{}}}
E
ebarros
Estranha maneira como vc faz a conexao.
pela documentação vc tem que fazer algo como abaixo usando a api sqljdbc.jar
driver: com.microsoft.sqlserver.jdbc.SQLServerDriver url: jdbc:sqlserver://localhost;database=NOME_DO_SEU_BD username:usuario do banco password:senha do banco
C
ClaudioA
Alguém sabe como montar a conexão com o JTDS?
IVANNETO7
Fala amigo!! Blz?
Não sei se vc ja resolveu o seu problema, porém se não resolveu tenta algo nesse sentido:
privatefinalStringdriver="net.sourceforge.jtds.jdbc.Driver";privatefinalStringurl="jdbc:jtds:sqlserver://Nro do ip:1433:Nome do Schema";privatefinalStringusuario="user";privatefinalStringsenha="senha";privateStatementstmt;publicConexaoSQLSERVER()throwsException{try{Class.forName(driver);conexao=DriverManager.getConnection(url,usuario,senha);stmt=conexao.createStatement();}catch(SQLExceptione){thrownewException("Erro ConexaoSQLSERVER: "+e.getMessage());}catch(ClassNotFoundExceptione){thrownewException("Erro ConexaoSQLSERVER: "+e.getMessage());}}