Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ms sql question

 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
Rich Stepanski
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 214
    IntelliJ IDE Java Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    Rich Stepanski
    Ranch Hand
    Posts: 59
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 10336
    Eclipse IDE Hibernate Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    whats the benefit of using jtds

    You see the benefit of jTDS when you use it with the Database it was written for...
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic