I want to create a JDBC connection with SQL Server Express 2005 when i tried the following code i got exception my code is
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class PrintFileToPrinter{
public static void main(String[] args){
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String dbURL = "jdbc:sqlserver://TOSHIBA-PC/SQLEXPRESS:1433;databaseName=COSEC;user=sa;password=22484;";
Connection conn = DriverManager.getConnection(dbURL);
if (conn != null) {
System.out.println("Connected");
}
}catch(ClassNotFoundException | SQLException exception){
exception.printStackTrace();
}
}
}
and the error showing is
com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the host localhost, named instance SQLEXPRESS has failed. Error: "java.net.SocketTimeoutException: Receive timed out". Verify the server and instance names, check that no firewall is blocking UDP traffic to port 1434, and 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:170)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.getInstancePort(SQLServerConnection.java:3163)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.primaryPermissionCheck(SQLServerConnection.java:953)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:816)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:716)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:841)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at textfilemaker.JdbcSQLServerConnection.main(JdbcSQLServerConnection.java:32)
database details are follows
