2020年/01月/09日

首页回退

各种JDBC URL

原文

Oracle

OracleDataSource dataSource = new OracleDataSource();
dataSource.setDatabaseName("high_performance_java_persistence");
dataSource.setURL("jdbc:oracle:thin:@localhost:1521/orclpdb1");
dataSource.setUser("oracle");
dataSource.setPassword("admin");

Mysql

MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setURL(
    "jdbc:mysql://localhost/high_performance_java_persistence"
);
dataSource.setUser("mysql");
dataSource.setPassword("admin");

PostgreSQL

PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setDatabaseName("high_performance_java_persistence");
dataSource.setServerName("localhost");
dataSource.setUser("postgres");
dataSource.setPassword("admin");

SQL Server

SQLServerDataSource dataSource = new SQLServerDataSource();
dataSource.setURL(
    "jdbc:sqlserver://localhost;instance=SQLEXPRESS;" +
    "databaseName=high_performance_java_persistence;"
);
dataSource.setUser("sa");
dataSource.setPassword("adm1n");

MariaDB

jdbc:mariadb://localhost/high_performance_java_persistence

Db2

jdbc:db2://localhost/high_performance_java_persistence

Informix

jdbc:informix-sqli://localhost:9088/sysuser:INFORMIXSERVER=hpjp

HSQLDB

JDBCDataSource dataSource = new JDBCDataSource();
dataSource.setUrl("jdbc:hsqldb:mem:test");
dataSource.setUser("sa");
dataSource.setPassword("");

H2

jdbc:h2:mem:high_performance_java_persistence

Derby

jdbc:derby:target/tmp/derby/hpjp;databaseName=high_performance_java_persistence;create=true