• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC connection from Eclipse to MSSQL server using sqljdbc4.jar

 
Ranch Hand
Posts: 67
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I am trying to make a jdbc connection to MS SQL server 2014 using sqljdbc4 from an Eclipse Web project,
without any luck whatsoever.

Here is what I have tried so far:
  • 1. Create a test class outside of the Web project, add jar to classpath and try to make a connection - success
  • 2. Place jar under project's WEB-INF/lib, add jar to classpath with and without adding a Web App Library
    for the project and try to make a connection - failure
  • 3. Place jar under the central Tomcat lib and try to make a connection - failure


  • Most of the forums have users who have succeeded by doing number 2. I am just starting out with JDBC and it took a
    while to figure out to get to this stage.
    But unfortunately, couldn't get any further. I am stuck at this point for close to 5 hours now and the frustrating thing is
    it works every time from a regular java project.
    Why is that so, when any kind of project in an IDE requires the jar to be in its classpath?

    Not sure how much help this will be of, but here is the code that I had come up with that tries to establish the connection.
    And it always leads to an SQLException : No suitable driver found for jdbc:sqlserver on the first line after 'try'.


    Kindly review and help.
     
    Bartender
    Posts: 3648
    16
    Android Mac OS X Firefox Browser Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Looking at your connection string, I'm a bit suspicious how your test app (outside web) works. You seem to be missing the database port.



     
    Saikrishnan Srivatsan
    Ranch Hand
    Posts: 67
    1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    SQL server is the only application running on that host name. The database client I use to connect also connects to that host. That is probably why.

    On an independent note, I have managed to get this working using Connection pool but still would be interested to know why the regular jdbc connection wouldn't work.
     
    Don't get me started about those stupid light bulbs.
    reply
      Bookmark Topic Watch Topic
    • New Topic