Results 1 to 1 of 1

Thread: Anyone proficient with Java (JDBC)?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sevasti's Avatar Biarchus
    Join Date
    Aug 2008
    Location
    They tell me it's a regular building but it sways like a house of cards when the wind blows
    Posts
    639

    Default Anyone proficient with Java (JDBC)?

    So I'm trying to build an app in netbeans that connects to a microsoft sql database but it just won't work. If anyone here has experience, please just take a look at my code to see if my syntax is sound. The only error I get is 'no suitable driver found'.

    Spoiler Alert, click show to read: 
    private void SetupDatabaseConnection()
    {
    try
    {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
    //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String URL = "jdbc:microsoft:sqlserver://XX.XX.XXX.XXX:YYYY;DatabaseName=XXXXX";
    String URL = "jdbc:sqlserver://XX.XX.XXX.XXX:YYYY;DatabaseName=XXXXX";

    this.iConn = DriverManager.getConnection(URL, User, Password);
    }
    catch (Exception e)
    {
    System.out.println(e.getMessage());
    }
    }

    I'm really at a loss here. I've added the sqljdbc.jar and sqljdbc4.jar to project library and followed the classpath tutorials but I have no idea how to verify that the project actually utilizes them.

    I can actually add the database manually to Services in netbeans and get contact but my app simply refuses to acknowledge its existence.

    I've scoured the internet for any kind of information relating to my problem but to no avail. The only thing I can think of is that the syntax in my url is faulty. I can connect to the database in question just fine through management studio and C# but Java refuse for some kind of reason. It doesn't really help that this is my first encounter with Java.

    Should anyone be able to help me solve the problem he, or she, will be heavily repped.

    EDIT: I've been haunted by this for days but I solved it. It was a petty syntax error. I've updated the code to the correct syntax should anyone find themselves in my previous situation.

    Now I only need to figure out how to rep myself.
    Last edited by Sevasti; May 20, 2011 at 04:25 PM.


    Et sekund er som et minutt her inne
    Minutt som en time. Time som et døgn
    Og du trur du ser ting å så klart
    Eg seier ikkje ett ord til før eg får en advokat

Posting Permissions

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