Results 1 to 2 of 2
Thread: Sql server connection problem
- 03-31-2008, 10:39 AM #1
Member
- Join Date
- Mar 2008
- Posts
- 4
- Rep Power
- 0
Sql server connection problem
I m using SQL server 2005 express. My default logon mode setting is set to-SQL server authentication and I can logon to using SQL server management studio express always. I enabled TCP/IP from SQL server configuration manager. The sqljdbc.jar (JDBC driver) is set correctly in classpath and 1433 port is allowed in windows firewall. YET, I can’t connect to sql server using the following code-
My host name is- Tanvir. So, in management studio express the server name is shown- TANVIR\SQLEXPRESSJava Code:import java.sql.*; public class testconn { Statement stmt; Connection con = null; String driver = "jdbc:sqlserver://"; String server = "localhost:1433;"; String db = "database=IDLC-Customer;"; String user = "userName=Tanvir;"; String pwd = "password=abcd;"; String connectName = driver + server + db + user + pwd; testconn() { try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con= DriverManager.getConnection(connectName); stmt=con.createStatement(); if(!con.isClosed()) System.out.println("Successfully connected to " + "SQL server using TCP/IP..."); } catch(Exception e) { System.err.println("Exception: " + e); } finally { try { if(con != null) con.close(); } catch(SQLException e) {} } } public static void main(String args[]) { testconn tc=new testconn(); } }
When I run the code it says-The TCP/IP connection to the host has failed.
Java.net.connectException:Connection Refused: Connect
One more thing, though 1433 port is allowed in windows firewall, I can’t connect to that port using telnet (e.g. telnet <server_host> 1433).I even disabled firewall and tried but in vain. PLEASE help me any brother.
- 03-31-2008, 12:46 PM #2
Similar Threads
-
Web-App server connection - How to hit the particular app server from the web server
By maruthi_s in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 07-15-2008, 06:11 PM -
connection problem
By subash in forum JDBCReplies: 5Last Post: 04-22-2008, 09:17 AM -
Java Serevr Connection Problem
By virendra_agarwal in forum JavaServer Faces (JSF)Replies: 0Last Post: 12-19-2007, 12:43 PM -
SQL Server 2005 Jdbc connection
By mgt83 in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 07-27-2007, 04:52 AM -
JDBC driver connection problem
By creativehacker in forum JDBCReplies: 3Last Post: 07-10-2007, 09:58 PM


LinkBack URL
About LinkBacks
Reply With Quote
me! :cool:
Bookmarks