总结几个常用数据库连接ipv6地址的连接字符串,以备参考。
oralce :
String ipv6url = "jdbc:oracle:thin:@[serverIP]:serverPort:serverBase;
mysql :
String ipv6url = "jdbc:mysql://address=(protocol=tcp)(host="+serverIP+")(port=serverPort)/"+serverBase;
sql server:
使用com.microsoft.sqlserver.jdbc.SQLServerDriver驱动
String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//设置连接属性
Properties pro = new Properties();
pro.setProperty("serverName", serverIP);
pro.setProperty("portNumber", serverPort);
pro.setProperty("databaseName", serverBase);
pro.setProperty("user", username);
pro.setProperty("password", password);
String url = "jdbc:sqlserver://;";
Connection conn = DriverManager.getConnection(url,pro);
使用net.sourceforge.jtds.jdbc.Driver驱动
<!-- maven 依赖-->
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
//设置驱动
String driver = "net.sourceforge.jtds.jdbc.Driver";
//连接字符串
String url = "jdbc:jtds:sqlserver:// [serverIP]:serverPort ;DatabaseName= serverBase;user=username;password=password;
mongodb
MongoClientURI connectionString = new MongoClientURI("mongodb://[serverIp]:serverPort”);
MongoClientURI client = new MongoClient(connectionString);
网友评论