java swing gui application with sql server 2005 as backend using windows authentication
i get this error when i execute my java application in netbeans 7.0 ide, any help regarding this will be appreciated.
SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host PRANAVVENKAT-PC, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties, check that an instance of SQL Server is running on the host and acce开发者_StackOverflow中文版pting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://PRANAVVENKAT-PC\\SQLEXPRESS;"+"databaseName=CallCenter";
Connection con = DriverManager.getConnection(connectionUrl);
PreparedStatement stat = con.prepareStatement("insert into customer (name,password)values(?,?)");
String name=jTextField1.getText();
String password=jPasswordField1.getText();
stat.setString(1, name);
stat.setString(2, password);
stat.executeUpdate();
} catch (SQLException e) {
System.out.println("SQL Exception: "+ e.toString());
} catch (ClassNotFoundException cE) {
System.out.println("Class Not Found Exception: "+ cE.toString());
}
Looks like your database is not running or something is blocking your path to it. Open up SQL Server Management Studio and verify the database is running and that you can connect to it from your machine.
Also, double check that your connection string is correct.
Just go to SQL server configuration manager and and then click "protocols for MSSQL server" enable all the options which are disabled. now next go to the control panel and open "local service" this will show all the services local SQL server and double click it then it will show its status if it is shows "running" then good other wise click "restart", next go back to your sql server restart the server and then connect your server.
精彩评论