Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: JDBC Connection from Single Computer

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JDBC Connection from Single Computer

    Hello,

    I知 having a problem with a JDBC connection to a remote SQL server. I知 taking a Java course and they have setup a remote server for us with a username and password. I am able to connect to the database fine from other computers but not the one that I use for development.

    It goes as far as loading the driver but then hangs (without throwing an exception) when it reaches the DriverManager.getConnection() method. I tried the same code on two other computers (Windows and Mac) from within the same network and it worked fine.

    The PC I知 having problems with is running Windows 7. I tried disabling the firewall and AVG anti-virus but not help. I知 running Eclipse.

    Any advice on what I could try? Thanks very much!

    Max


  2. #2
    Junior Member
    Join Date
    Feb 2011
    Location
    Polonnaruwa
    Posts
    6
    My Mood
    Cheerful
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JDBC Connection from Single Computer

    Can U post Your Source Code Here,
    Coding Part Use to Connect the DB

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JDBC Connection from Single Computer

    Quote Originally Posted by Salinda Anura View Post
    Can U post Your Source Code Here,
    Coding Part Use to Connect the DB
    Thank you for the reply, Salinda! As mentioned I'm not sure if the code is the problem because running the same project from another computer in the same network works just fine. I however, included it below, without the remote server and credentials obviously. Pretty simple:

    Class.forName(com.microsoft.sqlserver.jdbc.SQLServ erDriver);
    System.out.println("Driver Loaded");

    connection = DriverManager.getConnection(SQL_URL, SQL_USERNAME, SQL_PASSWORD);
    System.out.println("Connection Established");
    What happens on the computer that's being a problem is I can see the Driver Loaded message and then it just sits there. Ie: the windows mouse icon just starts spinning and nothing happens until I terminate the JVM. There is no exception thrown, nothing. If I run it from another computer, it connects and I can perform SQL DDL/DML no problem. I did a netstat and it is showing that a connection has been established to the Database URL but for some reason nothing is happening.

    Thanks again.
    Max

  4. #4
    Member
    Join Date
    Nov 2011
    Posts
    37
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: JDBC Connection from Single Computer

    Hi,
    Are you using proper jar for that.

    Core java
    Last edited by mr.miku; January 11th, 2012 at 07:17 PM.

  5. #5
    Junior Member
    Join Date
    Sep 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JDBC Connection from Single Computer

    Quote Originally Posted by mr.miku View Post
    Hi,
    Are you using proper jar for that.
    Thanks for the reply! Yes I am using the correct JAR, as mentioned the code works on other computers.
    I found out that there's a problem between one of the Microsoft patches and the latest Java 6 version. I downgraded to update 27 and it worked. Hopefully this helps someone else.

    Thanks,
    Max

Similar Threads

  1. Replies: 3
    Last Post: April 11th, 2011, 09:51 PM
  2. Replies: 0
    Last Post: March 26th, 2011, 11:07 AM
  3. jdbc connection problem
    By sny in forum JDBC & Databases
    Replies: 11
    Last Post: January 6th, 2011, 04:39 AM
  4. JDBC connection error
    By nrao in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 11th, 2010, 12:43 PM
  5. jdbc connection with phpmyadmin
    By anand_fevi in forum JDBC & Databases
    Replies: 1
    Last Post: May 13th, 2010, 02:26 AM