Search results
28 cze 2009 · Connect using the Oracle JDBC driver (oracle.jdbc.pool.OracleDataSource): String url = "jdbc:oracle:thin:@tcp://my-host:1522/my-service"; OracleDataSource ods = new OracleDataSource(); ods.setUser(userName); ods.setPassword(password); ods.setURL(url); Connection con = ods.getConnection();
Use the setConnectionProperties method to set the properties of the connection and the setConnectionCacheProperties method to set the properties of the connection cache.. If you are using the server-side internal driver, that is, the driverType property is set to kprb, then any other property settings are ignored.. If you are using the JDBC Thin or OCI driver, then note the following:
We can also include tnsnames.ora entries in the JDBC URL to connect to Oracle databases: jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<host>)(PORT=<port>))(CONNECT_DATA=(SERVICE_NAME=<service>))) Let’s see how to connect to our “my_servicename” service using entries from the tnsnames.ora file:
jdbc:oracle:thin:scott/tiger@//myhost:1521/myservicename. So I would try: jdbc:oracle:thin:@//oracle.hostserver2.mydomain.ca:1522/ABCD. Also, per Robert Greathouse's answer, you can also specify the TNS name in the JDBC URL as below:
26 gru 2014 · For load balancing between databases, I chose to use advanced 'custom JDBC URL' to connect database. E.g. custom JDBC URL jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=147.22.109.218)(port=1521))(ADDRESS=(PROTOCOL=TCP) (HOST=147.22.109.219)(port=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=147.22.109.220)(port=1521 ...
6 lis 2024 · Knowing the JDBC Driver Connection URL strings is mandatory if you want to connect to a relational database system from a Java application. If there is a database system that I forgot to add, add a comment and I’ll update the article.
11 mar 2020 · In this method, we specify all connection properties in a single URL string, for example: String dbURL = "jdbc:oracle:thin:tiger/scott@localhost:1521:productDB"; Connection conn = DriverManager.getConnection(dbURL); if (conn != null) { System.out.println("Connected"); }