Last active
April 22, 2016 08:48
-
-
Save Haosvit/ef679906ef3075389d8da5ecdcc707f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; | |
2. String connectionURL = "jdbc:sqlserver://" + hostname + ":1433;" | |
+ ";instance=." + ";databaseName=" + databaseName + ";user=" + user + ";password=" + password + ";"; | |
3. // register drive sql jdbc | |
Class.forName(driverName); | |
4. // create connection; | |
Connection conn = DriverManager.getConnection(connectionURL); | |
// create statement for execute queries | |
Statement st = conn.createStatement(); | |
5. Check port 1433, make sure it was opened | |
in cmd, type: netstat -an -P TCP | |
looking for port 1433 in the list, if it is not there, do the follow steps | |
5.1 Go to Sql server configuration manager, enable TCP/IP at Protocol for <Your SQL server instance> | |
5.2 Restart sever instance | |
5.3 Check again in cmd (netstat -an -P TCP) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment