0

I am using ubuntu 12.04 and wanted to connect to the MS SQL server database which is hosted in the same network. I was able to connect this using Squirrel , yet unable to connect from a java program. These are the tools I and .jars I am using . Intellij Idea is the tool jar are jtds-1.3.1.jar and sqljdbc4.jar Java version 1.7

I am hoping to develop a web application in the Ubuntu Environment , yet my database will be in Ms Sql windows table. Is this feasible ? Please intruct me step by step , and sample code to connect ms sql database which s hosted ina wondows environment

Rashen

2
  • 1
    Show your code. How did you create the JDBC connection, what error did you get? Commented Nov 4, 2014 at 9:55
  • "I was able to connect this using Squirrel, yet unable to connect from a Java program" - SQuirrel is a Java program. So your problem (which you didn't specify) is in your program code, not in the connection itself. Commented Nov 4, 2014 at 10:28

3 Answers 3

1

Both microsoft's driver and jTDS works on linux.

Their web site have example jdbc urls.

Sign up to request clarification or add additional context in comments.

1 Comment

Did work, actually the user which was created only had the Windows Authentication, yet created a user with SQLAuthentication and this did work.
1

Don't care about the OS. Have you tried the recommended way to connect using the MS SQL JDBC Driver?

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

String dbHostName = "windowsHostName";
String dbName = "myDb";
String dbUserName = "myUserName";
String dbPassword = "topSecret";

String connectionUrl = "jdbc:sqlserver://" + dbHostName + ":1433;" +
   "databaseName=" + dbName + ";user=" + dbUserName + ";password=" + dbPasword + ";";
Connection con = DriverManager.getConnection(connectionUrl);

Comments

0

It does not change anything that your DB is hosted on Linux / Windows, as long as you can access it through your network.

There is a post where you can see how to connect to your DB from Java using jTDS: Connect to SQL Server 2012 using jTDs

If it does not solve your problem, can you give us your exact error message?

2 Comments

The database is not hosted on Linux. The client is.
As I've just said, it does NOT change anything that your DB is not in Linux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.