• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Facing the problem of connecting servlet to Sql Server 2008.

 
Prashant Chindhade
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • 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
     
    Rob Spoor
    Sheriff
    Pie
    Posts: 20750
    68
    Chrome Eclipse IDE Java Windows
    • Mark post as helpful
    • send pies
    • 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
    • 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
    Pie
    Posts: 20750
    68
    Chrome Eclipse IDE Java Windows
    • Mark post as helpful
    • send pies
    • 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
    • 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
    Pie
    Posts: 20750
    68
    Chrome Eclipse IDE Java Windows
    • Mark post as helpful
    • send pies
    • 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
    • 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
    Pie
    Posts: 20750
    68
    Chrome Eclipse IDE Java Windows
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You're welcome.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic