My company has a large SQL Server database that was created and maintained with Microsoft SQL Server 2008. I am new to working with SQL Server on a large scale like this. I want to be able to automate some of the common maintenance operations that we do and I want to do so using Java.
My question is this: How do I use a Java application to execute SQL statements on our database? I also would like to be able to use this application to create a small test database so that I can test some of the functions on a small scale before I use them on the live database.
I have been doing some reading online and found information on using JDBC to create the connection with the database and then use a connection object with a statement object to execute a statement. The problem is that this requires drivers and I cant seem to pin down with driver will do what i need it to do. Is there an easier way to do this? If not, where can I find a driver that will do what I need it to do.
Thank you for your help!
-
I'd start here : microsoft.com/en-gb/download/details.aspx?id=11774. Download and install and then find a JDBC tutorial and follow itDaveH– DaveH2014年03月28日 13:54:26 +00:00Commented Mar 28, 2014 at 13:54
-
At first glance this seems like it is what I was looking for. I wish you would have posted that as an answer though so if it works I could mark it as the answer.Dead_Jester– Dead_Jester2014年03月28日 14:02:25 +00:00Commented Mar 28, 2014 at 14:02
-
Why are you unable to pin down which driver to use?Mark Rotteveel– Mark Rotteveel2014年03月28日 15:53:09 +00:00Commented Mar 28, 2014 at 15:53
1 Answer 1
You may use JDBC. If you use Maven you could simply add the artifact "sqljdbc4".
The JDBC driver: http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774
A JDBC tutorial: http://www.amazon.com/JDBC¿-API-Tutorial-Reference-Edition/dp/0321173848