Java with MS SQL? - java

I am new in Java world. I worked before with .NET environment with MS SQL database, I would like to ask if I can still use MS SQL database with Java? and what tools do I need to proceed with that?

These days, you can use just about any database you want. Microsoft provides JDBC drivers for your use. You can get everything you need here: http://msdn.microsoft.com/en-us/sqlserver/aa937724
This link will allow you to download the JDBC driers an has usage info.

Here's the link to download: http://msdn.microsoft.com/en-us/sqlserver/aa937724

Related

Java - connecting to a SQL Server database on Linux

I've downloaded and imported into my project this JDBC driver that supposedly supports Linux (albeit tested only on SUSE Linux).
What I want is to be able to use a .mdf database through Java on Linux. The queries obviously need something to run on, not simply connect to a database - if I am understanding this correctly.
I found a question on SO that seems to have valuable information concerning my issue.
So I was thinking a FreeTDS + JDBC combination. Will queries execute as expected or do I have to go use the database natively, on Windows? The latter basically crushes OS agnosticism that Java provides which I would like avoid, if possible.
The database itself isn't anything fancy, only a few tables - this is merely a school assignment, after all.
I will provide additional information, if needed.
An mdf file can be an old (JET based) Microsoft Access database file, so a JDBC driver for SQL Server, a totally different product, isn't going to help you much. Here on SO there are a couple of posts that explain how to use the JDBC-ODBC bridge to access Access databases via the ODBC driver detour, but since you specifically mention Linux that's not going to help you.
I see two possible (free) approaches:
use the open source jackcess package that allows Java programs across platforms to open, read and write MS Access database
transfer the content of the MSAccess database file to some database that has native Java drivers (that is, most of them that are not MS Access).
However, an mdf file could also be a SQLServer database, but using that database under Linux is also going to be quite tricky, as you'll need some edition of SQL Server to open it - see here for some details on how to "attach" such an mdf file to an installed instance of SQLServer - but to my knowledge there is no edition of SQL Server that runs under Linux. So, unless you can find some Windows machine to run SQLServer on, and then connect to it using the JDBC driver you have both options mentioned before may be valid alternatives (ie, option 1 = copy your data into an MSAccess file and access that file with jackcess or option 2, copy the data into some Linux-tolerant database with a decent JDBC driver and use that)
Some people have been mislead by my question (I am not a native speaker of English, could be that), the database was meant to be run locally (explicitly not on a remote server) which simply cannot happen with the SQL Server + Linux combination. Wine is a possibility, but that is just too much hassle. So, the solution is either to simply use SQL Server on Windows or use an alternative cross-platform RDBMS like MySQL.
Nevertheless, I'll accept fvu's edited answer and would like to thank other users for the time they've invested in their own answers.

Suitable database for application

I need to find a suitable database for my application, that satisfy following criteria,
Zero intallation
Zero configuration
Portable (client wants database file to be able to shift from one machine to another manually.)
Please suggest me a suitable database for the above criteria.
For java I will go with Apache Derby (aka Java DB).
I recommend JavaDB, you can use it as an in process database and it has good performance. I have used it in several projects, mainly in Java Swing desktop applications.
I would recommand h2
Sounds like you should use SQLite for that.
Have a look at Java and SQLite for how to interact with the SQLite databae from Java.
for me mongodb also meets these criteria (unless you really need sql database)

SQL Server Libraries for Java

I'm curious to find what SQL Server libraries are available for Java.
At present we are using the com.microsoft.jdbc.sqlserver.SQLServerDriver driver. I think this was downloaded from the Microsoft site a while ago.
What alternative libraries are available?
Many thanks,
Andez
Seconding the open source jTDS Driver. It also works perfectly with Hibernate.
DataDirect is a well known alternative (used by many vendors) but also others such as
connx
attunity
i-net
Easysoft
JTDS is an open source alternative
NB: I have only used the MS driver, DataDirect and the i-net drivers suceccfully in production, mostly prior to the MS JDBC driver release.

How to connect between MySQL and Eclipse Java?

How do I establish database connectivity between MySQL and Eclipse Java?
Lots of ways:
Hibernate
EJB (make sure you go with version 3!)
Roll your own solution with JDO/JDBC
And I'm sure there are plenty of other ways to do it as well.
You need a JDBC driver for MySQL in your application classpath which then registers automatically with DriverManager.
You can then use the techniques described in http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html except you need to have the connection string (starting with jdbc:...) adapted to your precise scenario. That is described in the documentation for the JDBC driver you choose to use.
There are plenty of jdbc tutorials if you want to build your own solution. MYsql has a Using MySQL With Java page that has links to tutorials, presentations, blogs etc. The first tutorial looks like it covers everything from installing the database to accessing it from the java program.

Connecting to MSAccess with Java

I am developing my project in Java. I would like to know how I can connect to MSAccess.
Any links, or small examples would be greatly appreciated.
Jackcess is a good tool to read MSAccess databases without ODBC.
I've had good luck with using UCanAccess (http://ucanaccess.sourceforge.net/site.html) which allows both read and write access to the database
I used this article, on javaworld when I first started JDBC programming. And may I suggest using pure Java DB's or MySQL's or Oracle's personal editions unless you have a specific need for MS Access.

Categories

Resources