Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-31-2008, 11:39 AM
Member
 
Join Date: Mar 2008
Posts: 1
tanvirtonu is on a distinguished road
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-
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(); } }
My host name is- Tanvir. So, in management studio express the server name is shown- TANVIR\SQLEXPRESS
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-31-2008, 01:46 PM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 237
DonCash will become famous soon enoughDonCash will become famous soon enough
The code all looks good to me. Are you able to telnet to any other open port on your machine?
__________________
Did this post help you? Please
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
me!

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|| Don't forget to:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
connection problem subash Database 5 04-22-2008 10:17 AM
Web-App server connection - How to hit the particular app server from the web server maruthi_s Enterprise JavaBeans 1 01-06-2008 01:32 PM
Java Serevr Connection Problem virendra_agarwal JavaServer Faces 0 12-19-2007 01:43 PM
SQL Server 2005 Jdbc connection mgt83 JavaServer Pages (JSP) and JSTL 0 07-27-2007 05:52 AM
JDBC driver connection problem creativehacker Database 3 07-10-2007 10:58 PM


All times are GMT +3. The time now is 06:41 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org