This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes ms sql question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ms sql question" Watch "ms sql question" New topic
Author

ms sql question

Rich Stepanski
Ranch Hand

Joined: Aug 24, 2004
Posts: 59
I have a dat file which supposedly uses ms sql. How can I connect with this file through java? I have a jar with an ms sql driver. I dont have an ms sql server? and i dont really know anything about this. Thanks.
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

Hi
I can not completely understand your question , if you explain more then we can give you better suggestion.
If you want to use an MSSQL server database (MDF file) then you should have access to an SQL server to attache it to the server and then connect to it via JDBC driver wich is provided by micosoft or Opensource ( http://jtds.sourceforge.net/ ).

you mentioned a dat file ? what is the content of the dat file ? is it a sql server database ? or you made it yourself in an structured way?
for example you insert some object into it?


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
Rich Stepanski
Ranch Hand

Joined: Aug 24, 2004
Posts: 59
We have a satelite tracking program through our cell phone company that produces a dat file containing all unit locations. The only description on the file was I was given was that it used ms sql.
So I'm assuming its not an sql server? Objects do get inserted into it, but I can't do it manually. Again, I don't really know anything about it. I'm going to dig around to try and find some more out about it. Thanks.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

A .dat file is how MSSQL usually stores backups of databases. I'd use Enterprise Manager to restore the DB using this file before trying to access any data in it. If you absolutely must use Java to handle the file you could restore it by calling isql via Runtime.exec().


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Rich Stepanski
Ranch Hand

Joined: Aug 24, 2004
Posts: 59
Ok, the dat file isn't the database or what I'm trying to access now. The tracker program accesses a database server named DBSIAMTB. I'm using the jtds driver, but I can't connect to the database. I keep getting connections refused. Heres my code...



I'm going to try getting at it with the Enterprise Manager as you suggested, however in the end I have to be able to access this from java. Thanks.
[ May 27, 2005: Message edited by: Rich Stepanski ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

You might find the FAQ at the jTDS site useful. There's a bunch of MSSQL configuration stuff which can stop you being able to connect. The headline things to look out for are:
  • Your IP Address is correct (a DNS name would be safer)
  • Your Username and password are correct
  • The format of you JDBC url is correct (which it must be otherwise DriverManager.getConnection(url) would complain with a "No Suitable Driver" exceptions)
  • The authentication mechanism MSSQL is configured to use is correct (SQL Server and Windows)
  • MSSQL is configured to accept TCP/IP as an enabled protocol. Its also worth checking the network DLLs it is using are up to date. I've seen unpatched versions of MSSQL complain in ways like this.


  • ***Correction***: my memory was hazy, MSSQL uses .BAK files for backups not (typically) .DAT. Can you open this file with a text editor? Or is it a binary file? If you can, what do the contents look like?
    [ May 27, 2005: Message edited by: Paul Sturrock ]
    Edwin Keeton
    Ranch Hand

    Joined: Jul 10, 2002
    Posts: 214

    I don't think you're using the correct driver.

    It sounds like you're using a DBISAM database. I'm pretty sure there isn't a jdbc driver for them. I think you need to use an odbc driver and jdbc-odbc bridge to read DBISAM tables with Java.

    Tim Young at Elevate Software (the maker of DBISAM) is very helpful and can probably get this to work for you if you have trouble.


    SCJP, SCWCD
    Rich Stepanski
    Ranch Hand

    Joined: Aug 24, 2004
    Posts: 59
    I looked into it a little more and we are in fact using a DBISAM database. I set it up with an odbc driver and everything worked very well. Thanks for the help and sorry about the vagueness.

    The odbc driver seemed much easier to set up - whats the benefit of using jtds? (if that makes sense) Thanks again everyone.
    Paul Sturrock
    Bartender

    Joined: Apr 14, 2004
    Posts: 10336


    whats the benefit of using jtds

    You see the benefit of jTDS when you use it with the Database it was written for...
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: ms sql question
     
    Similar Threads
    LDF File
    Import CDR File into Sql Database
    SQL Dates
    jtds error while connecting to MS SQL server 2008
    how to host jsp project in third party server.