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.

Page 1 of 2 12 LastLast
Results 1 to 25 of 26

Thread: JAVA SQL Connection

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JAVA SQL Connection

    I'm getting this error "com.microsoft.sqlserver.jdbc.SQLSer verDriver"

    I'm trying to create an applet that can be sent to many machines on a LAN network, how can I resolve this?

    Do I need to do something to each machine?

    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");


  2. #2
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: JAVA SQL Connection

    do you have the driver set on the class path?

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: JAVA SQL Connection

    What you posted is not an error, not a complete one anyway. Post the entire error text, copied from exactly as it appears at your end.

  4. #4
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    Quote Originally Posted by jocdrew21 View Post
    do you have the driver set on the class path?

    What's that?

  5. #5
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: JAVA SQL Connection

    Looks like you are using SQL and not mySQL right.
    Microsoft JDBC Driver for SQL Server

    Once you download the driver, open it and find the jar file. Right click the file you are using and select "Build Path", then "Add External Archives", select the jar file that you just found and thats it.

  6. The Following User Says Thank You to jocdrew21 For This Useful Post:

    GregBrannon (September 20th, 2014)

  7. #6
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    Does that get installed on each machine I use my applet on or does it get installed within my applet

  8. #7
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    Quote Originally Posted by Kiwis View Post
    Does that get installed on each machine I use my applet on or does it get installed within my applet
    anyone?

  9. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA SQL Connection

    Can you put the missing classes in your jar file?
    If you don't understand my answer, don't ignore it, ask a question.

  10. #9
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    Is this a file that can be included in my jar file?
    Is it another .exe file? does it need admin rights to run?

  11. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA SQL Connection

    Class.forName("com.microsoft.sqlserver.jdbc.SQLSer verDriver");
    That would be a java class file.
    If you don't understand my answer, don't ignore it, ask a question.

  12. #11
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    I'm trying to connect to a database

    Connection con = DriverManager.getConnection(connectionUrl);
    System.out.println("Connected.");

    } catch(Exception e){
    System.out.println("Error " + e.getMessage());
    }
    and that it my output?

    what is wrong?

  13. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA SQL Connection

    To see what is wrong, call the printStackTrace() method in the catch block. It will give a fuller error message.
    If you don't understand my answer, don't ignore it, ask a question.

  14. #13
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    Quote Originally Posted by Norm View Post
    To see what is wrong, call the printStackTrace() method in the catch block. It will give a fuller error message.

    java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:4 24)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 57)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:259)
    at learn.DB.dbConnect(MainGUI.java:137)
    at learn.MainGUI.main(MainGUI.java:112)

  15. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA SQL Connection

    java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    Make sure the class (or the jar containing it): com.microsoft.sqlserver.jdbc.SQLServerDriver is on the classpath
    If you don't understand my answer, don't ignore it, ask a question.

  16. #15
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    Ok very very new to this

    How do I do that

  17. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA SQL Connection

    The java command has an option: -cp that can be used to put a class or jar with classes on the classpath.
    For example (on windows) this adds the current dir (.) and the jsoup.jar to the classpath:
    D:\Java\jdk1.7.0.7\bin\java.exe -cp .;jsoup.jar TheClassFileHere
    If you don't understand my answer, don't ignore it, ask a question.

  18. #17
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    Quote Originally Posted by Norm View Post
    The java command has an option: -cp that can be used to put a class or jar with classes on the classpath.
    For example (on windows) this adds the current dir (.) and the jsoup.jar to the classpath:
    D:\Java\jdk1.7.0.7\bin\java.exe -cp .;jsoup.jar TheClassFileHere

    and when im using netbeans?

  19. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA SQL Connection

    sorry, I don't know anything about netbeans.
    If you don't understand my answer, don't ignore it, ask a question.

  20. #19
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    Can anyone please help?

    I'm not sure what i'm doing here..

  21. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA SQL Connection

    Please explain what you are trying to do in more detail. What isn't working?

    If this is a question about how to use your IDE, I'll move the thread to the IDE section.
    If you don't understand my answer, don't ignore it, ask a question.

  22. #21
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    I'm trying to connect to a SQL Server and am getting this error
    java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:4 24)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 57)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:259)
    at learn.DB.dbConnect(MainGUI.java:137)
    at learn.MainGUI.main(MainGUI.java:112)
    I don't know what is wrong

  23. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA SQL Connection

    what is wrong
    The java machine can not find the definition for the com.microsoft.sqlserver.jdbc.SQLServerDriver class. It's definition needs to be on the classpath.
    This has been discussed before.
    If you don't understand my answer, don't ignore it, ask a question.

  24. #23
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    how do i do that?

  25. #24
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA SQL Connection

    how do i do that?
    That post was the same as post#15. So we are now going in circles.
    My response is what was said in post#16

    If this is a netbeans setup problem, I'll move this thread to the Netbeans section.
    If you don't understand my answer, don't ignore it, ask a question.

  26. #25
    Junior Member
    Join Date
    Aug 2014
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA SQL Connection

    I guess this is my question, how do I that in netbeans?

    Post 16 is not clear to me what i need to do

Page 1 of 2 12 LastLast

Similar Threads

  1. SQL statement is not executed! java.sql.SQLException: General error
    By ppz in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 20th, 2014, 05:36 PM
  2. Error in connection sql server 2008 using netbeans 7.2
    By Indrajeet in forum JDBC & Databases
    Replies: 1
    Last Post: January 20th, 2013, 11:38 PM
  3. connection with microsoft sql server 2008 using netbeans
    By Indrajeet in forum JDBC & Databases
    Replies: 1
    Last Post: January 15th, 2013, 07:18 AM
  4. Connection String for Sql Server
    By manjula in forum JDBC & Databases
    Replies: 1
    Last Post: July 11th, 2012, 11:12 AM
  5. [SOLVED] How to modify core Java interface java.sql.Statement.execute(String sql)?
    By amughost in forum Java Theory & Questions
    Replies: 6
    Last Post: June 9th, 2012, 04:31 PM