Skip to content

Instantly share code, notes, and snippets.

@PingNote
Last active December 17, 2015 04:19
Show Gist options
  • Save PingNote/9ee164d396b0f29e5893 to your computer and use it in GitHub Desktop.
Save PingNote/9ee164d396b0f29e5893 to your computer and use it in GitHub Desktop.
Microsoft JDBC Driver for SQL Server
import java.sql.*;
import java.util.Properties;
public class MSSQLDemo {
private static final String CONNECTION = "jdbc:sqlserver://ip_address:1433";
public static void main(String[] args) throws SQLException {
Properties p = new Properties();
p.put("databaseName", "dbName");
p.put("user", "sa");
p.put("password", "Pa$$w0rd");
// Now try to connect
Connection c = DriverManager.getConnection(CONNECTION, p);
System.out.println("\nIt works !\n");
c.close();
}
}
import java.sql.*;
import java.util.Properties;
public class MySQLDemo {
//private static final String CONNECTION = "jdbc:mysql://127.0.0.1/emotherearth";
private static final String CONNECTION = "jdbc:mariadb://127.0.0.1/emotherearth";
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Properties p = new Properties();
p.put("user", "yourusername");
p.put("password", "changeit");
// Now try to connect
Connection c = DriverManager.getConnection(CONNECTION, p);
System.out.println("It works !");
c.close();
}
}
當JAVA 遇上MicroSoft SQL -- JDBC 的使用
http://guruqiu.pixnet.net/blog/post/1133834
Connecting to SQL Server 2000 from Windows / Unix using JDBC
http://www.akadia.com/services/sqlsrv_jdbc.html
Microsoft SQL Server JDBC 驅動程式 3.0
https://www.microsoft.com/zh-tw/download/details.aspx?id=21599
jTDS is an open source 100% pure Java (type 4) JDBC 3.0 driver for Microsoft SQL Server (6.5, 7, 2000, 2005, 2008 and 2012) and Sybase Adaptive Server Enterprise (10, 11, 12 and 15).
http://jtds.sourceforge.net/
http://sourceforge.net/projects/jtds/
如何從 Unix (或 Linux)連資料庫?
http://web.nchu.edu.tw/~jlu/cyut/java4.shtml
使用 JDBC 驅動程式連接到 SQL Server
https://msdn.microsoft.com/zh-tw/library/ms378672(v=sql.110).aspx
Java資料庫連線
https://zh.wikipedia.org/zh-tw/Java%E6%95%B0%E6%8D%AE%E5%BA%93%E8%BF%9E%E6%8E%A5
--
https://www.google.com.tw/search?q=java+sql+server
修正: SQL Server 無法繫結在啟動時的 TCP/IP 連接埠
https://support.microsoft.com/zh-tw/kb/312935
主要原因: SSNETLIB.DLL Version 8.0.194
SQL Server 2000 Security Tools
https://www.microsoft.com/zh-tw/download/details.aspx?id=10904
修正方式: 此工具將把 SSNETLIB.DLL 更新為 Version 8.0.311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment