Results 1 to 4 of 4
  1. #1
    pink123 is offline Member
    Join Date
    Feb 2011
    Posts
    84
    Rep Power
    0

    Default Connecting to sqlserver from Java

    I am using Java 1.6.0_27 ,SQL server 2005,Weblogic 10.3.5.
    I am using weblogic.jdbc.sqlserver.SQLServerDriver as the driver class
    and jdbc:bea:sqlserver://hostname:1433 jdbcProperties
    where jdbcProperties={db=Test, user=test, password=test, ProgramName
    =WebLogic JDBC Driver}

    Properties jdbcProperties = new Properties();
    jdbcProperties.put("user", user);
    jdbcProperties.put("password", password);
    jdbcProperties.put("db", DB);
    jdbcProperties.put("ProgramName", "WebLogic JDBC Driver");
    Driver jdbcDriver = (weblogic.jdbc.sqlserver.SQLServerDriver )Class.forName(DRIVER).newInstance();
    Connection sqlCon = jdbcDriver.connect(PROTOCOL + "//" + server + ":1433", jdbcProperties);

    sqlConn is returned as null.I am not able to connect to the database
    Is there some issue with the driver?This code worked fine with Java 1.5_06 and Weblogic 9.1.
    I just did an upgrade to Weblogic 10.3.5 and Java 1.6.0_27.
    Please help

  2. #2
    meyerstravisl is offline Member
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Default Re: Connecting to sqlserver from Java

    Convert

    Java Code:
    Driver jdbcDriver = (weblogic.jdbc.sqlserver.SQLServerDriver )Class.forName(DRIVER).newInstance();
    to

    Java Code:
    Driver jdbcDriver = ("weblogic.jdbc.sqlserver.SQLServerDriver");
    Class.forName(jdbcDriver).newInstance();
    I'm not sure if that's causing your problems because if you don't have a String DRIVER variable it shouldn't compile to begin with.
    It might help if you copy past your code along with the stacktrace of your error

  3. #3
    clydedoris is offline Member
    Join Date
    Feb 2010
    Posts
    80
    Rep Power
    0

    Default Re: Connecting to sqlserver from Java

    Try printing the content of jdbcDriver and see what it contains tos see which variable and when in the program it becomes null.

    If it were a connectivity problem, there should be an exception error. If you have an exception handler, try printing out any error caught.
    [why are you annoyed with my sig?]

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,947
    Rep Power
    19

    Default Re: Connecting to sqlserver from Java

    Oh for god's sake...reporting.

Similar Threads

  1. Cannot connect to sqlserver 2008 with JDBC
    By alexander.s in forum JDBC
    Replies: 4
    Last Post: 03-13-2011, 12:02 AM
  2. JDBC commands for connecting to sqlserver
    By sudukrish in forum Advanced Java
    Replies: 7
    Last Post: 04-22-2009, 09:48 AM
  3. Replies: 1
    Last Post: 10-16-2008, 02:09 PM
  4. Tomcat with SQLSERVER 2005
    By bbq in forum JDBC
    Replies: 1
    Last Post: 07-05-2007, 04:40 AM
  5. SQLServer 2000 EXCEPTION
    By Heather in forum JDBC
    Replies: 3
    Last Post: 06-29-2007, 03:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •