Connect SQL Server With Android Application| JDBC Driver integration

SQL server is a very widely used database management system and is really useful and easy to use than others! So after spending hours, I found some way to integrate my android application with SQL server

First, download the JTDS driver for your OS.

Now How to add this driver to SQL server …. very easy but you must remember the way! watch my video


To add jar files to your android studio:

  1. Right click on app > New > Module.
  2. A window will open where you can find jar files when you scroll down.
  3. Select the widget another window will open, find the location of your jar and select.
  4. Finish. That is it you can start creating projects with SQL server after the build is finished.

Now we are going to make a java class to connect SQL server and android studio. Remember this class is the heart of your every android project with SQL server.

Use Imports Correctly.


You can now use connectionclass object to make connection with your database and perform queries on your table.

You are all set, now test your application by making a simple login screen.

Strict Mode:

StrictMode is a developer tool which detects things you might be doing by accident and brings them to your attention so you can fix them.

StrictMode is most commonly used to catch accidental disk or network access on the application’s main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications.


  1. Always keep your connection class separate. So that if you change your server address, you just need to modify one file.
  2. Whenever you are using a SQL query. Do not run it on main thread otherwise, you will get errors like:  Main Thread id having load skipped 144 thread.
  3. You can Async Task to run your query on the background while the screen shows Loading or progress dialog.
  4. You can also use Runnable and threads to move the execution of SQL query from the main UI thread to Created thread.
  5. Use Logcat To display errors you face during your execution.
  6. Create a package for all the different purpose java classes.


How useful was this post?

Do not forget to rate! this helps us to Improve.

Average rating / 5. Vote count:

Read More Like This..

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Safiya Akhtar

Safiya Akhtar is Android Application Developer in India. She is currently working as a public consultant for career and education too, besides blogging and freelancing. She believes that it is never too late or too early to start what you have always dreamed of.

3 thoughts on “Connect SQL Server With Android Application| JDBC Driver integration

Your Views And Question are Welcome Here!