• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Facing the problem of connecting servlet to Sql Server 2008.

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have sample application that access database. following is the code.


  • i have .sdf database.


  • this is the code but it is giving this error
     
    Sheriff
    Posts: 22644
    123
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    If it's an SQL Server Express installation, that is using a named instance called "SQLExpress" and that could be using a different port. Try "jdbc:sqlserver://localhost\\SQLExpress;DatabaseName=MyDatabase" instead.

    If it's a "regular" SQL Server installation, make sure you have indeed installed the default instance. If that's the case, check its network settings to make sure TCP is enabled. It may be disabled by default.
     
    Prashant Chindhade
    Ranch Hand
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Rob Spoor wrote:If it's an SQL Server Express installation, that is using a named instance called "SQLExpress" and that could be using a different port. Try "jdbc:sqlserver://localhost\\SQLExpress;DatabaseName=MyDatabase" instead.

    If it's a "regular" SQL Server installation, make sure you have indeed installed the default instance. If that's the case, check its network settings to make sure TCP is enabled. It may be disabled by default.



    thanks Rob for your reply.
    but as i mentioned i have .sdf database i don't know weather it is sql express or normal installation.
    i just can't find way to connect my app to .sdf file.

    thanks in advance for your help.
     
    Rob Spoor
    Sheriff
    Posts: 22644
    123
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    A .sdf file is not a database. SQL Server uses .mdf for its data and .ldf for its transaction logs. Neither can be directly accessed, only through a running SQL Server. If you can't see a database in SQL Server Management Studio (or similar tools), you can't connect to it.
     
    Prashant Chindhade
    Ranch Hand
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I can see the database in sql server management studio but i can't find way to connect it.
    I think it is sql server compact edition database.
     
    Rob Spoor
    Sheriff
    Posts: 22644
    123
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    OK, so apparently .sdf files are different. They are apparently standalone files that are not running through an actual server.

    According to several sources I've found through Google, there is no official JDBC support for SQL Server Compact Edition. You should either try to find a third party JDBC driver that does support it, or switch to a different database type. That can be SQL Server 2008 (Express) if you want to keep using SQL Server, or if you want to continue using a file then you have to abandon SQL Server and instead switch to Derby, HSQLDB, SQLite or another file-based SQL database system. Whatever you do, stay away from Microsoft Access; although it has its merits, I would never recommend using it if you have alternatives.
     
    Prashant Chindhade
    Ranch Hand
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Rob Spoor wrote:OK, so apparently .sdf files are different. They are apparently standalone files that are not running through an actual server.

    According to several sources I've found through Google, there is no official JDBC support for SQL Server Compact Edition. You should either try to find a third party JDBC driver that does support it, or switch to a different database type. That can be SQL Server 2008 (Express) if you want to keep using SQL Server, or if you want to continue using a file then you have to abandon SQL Server and instead switch to Derby, HSQLDB, SQLite or another file-based SQL database system. Whatever you do, stay away from Microsoft Access; although it has its merits, I would never recommend using it if you have alternatives.



    thank you very much. now my all doubts are clear. and i will try using sql server express or dedicated server.
    thanks once again.
     
    Rob Spoor
    Sheriff
    Posts: 22644
    123
    Eclipse IDE Spring VI Editor Chrome Java Windows
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You're welcome.
     
    Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
    Free, earth friendly heat - from the CodeRanch trailboss
    https://www.kickstarter.com/projects/paulwheaton/free-heat
    reply
      Bookmark Topic Watch Topic
    • New Topic