1.Mysql
Class.forName("com.mysql.jdbc.Driver");
String URL="jdbc:mysql://localhost:3306/db_mysql";
命令连接:mysql -h 172.19.1.2 -P 6033 -u hive -phive
2.Oracle
Class.forName("oracle.jdbc.driver.OracleDriver");
String URL="jdbc:oracle:thin:@loaclhost:1521:db_orcl";
3.Postgresql
Class.forName("org.postgresql.Driver");
String URL="jdbc:postgresql://localhost:5432/db_name";
命令连接:psql -d test -U test_user -p 5212 -h 172.168.2.1
.pgclass 文件添加免密:172.168.2.1:5212:test:test_user:password
4.Sql Server
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=db_sql";
5.DB2
Class.forName("com.ibm.db2.jdbc.app.DB2.Driver");
String URL="jdbc:db2://localhost:5000/db_db2";
6.Hive
Class.forName("org.apache.hive.jdbc.HiveDriver");
String URL="jdbc:hive2://localhost:10000";
命令连接:beeline -u jdbc:hive2://hadoopmaster1:10000 -n etl
通用
String Username="username";
String Password="password";
Connection con=DriverManager.getConnection(URL,Username,Password);