Java connection with sql server 2008 r2 type 4 -


Hello iam Eclipse and I obtained using 2008 R2 as the SQL Server database such an error

< Pre> com.microsoft.sqlserver.jdbc.SQLServerException: connection of host RITHISHABINAV failed, sqlexpress named example. Error: "java.net.SocketTimeoutException: Check the deadline" server and instance name and check to see if a firewall port is not blocking UDP traffic for 1434. For SQL Server 2005 or later, verify that the SQL Server Browser service is running on the host. At com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError (SQLServerException.java:190) com.microsoft.sqlserver.jdbc.SQLServerConnection.getInstancePort (SQLServerConnection.java3589) at com.microsoft.sqlserver.jdbc.SQLServerConnection.primaryPermissionCheck on com.microsoft.sqlserver.jdbc.SQLServerConnection.connect (SQLServerConnection.java:827) on com.microsoft.sqlserver.jdbc.SQLServerConnection.login (SQLServerConnection.java:972) (SQLServerConnection.java:1225) on com.microsoft. On sqlserver.jdbc.SQLServerDriver.connect (SQLServerDriver.java:1012) java.sql.DriverManager.getConnection (Unknown Source) at com.serv.sqlservertype4.fun on java.sql.DriverManager.getConnection (Unknown Source) (sqlservertype4.java : com.serv.sqlservertype4.main (sqlservertype4.java:39) to 17)

and I address this

  package com.serv;  

Import java.sql.Connection; Import java.sql.DriverManager; Import java.sql.ResultSet; Import java.sql.Statement;

public class sqlservertype4 {

  void fun () {try {Class.forName ( "com.microsoft.sqlserver.jdbc.SQLServerDriver"); String connectionRuril = "jdbc: sqlserver: // RITHISHABINAV \\ SQLEXPRESS; database = tempdatabase; integrated security = true;"; Connection conn = DriverManager.getConnection (connectionUrl); Statement stmt = conn.createStatement (); Results reset rs = stmt.executeQuery ("select from client"); While (rsnext ()) {System.out.println (rs.getString ("id")); Println (rs.getString ("name")); }} Hold (exception e) {e.printStackTrace (); }} Public static zero main (string [] args) {sqlservertype4 b = new sqlservertype4 (); B.fun (); }  

}

I think you have the wrong connectionURL , you must create as vURL`:

  JDBC: sqlserver: // HOST_SERVER: SQL_SERVER_PORT; DatabaseName = Database_Name;  

But if you are using named instance to connect to your database (rather than port numbers), then the following URL Use Template

jdbc: sqlserver: // DATABASE_HOST \\ INSTANCE_NAME; Database Name = DATABASE_NAME;

Comments