Skip to content

Commit

Permalink
Added UcpExample
Browse files Browse the repository at this point in the history
  • Loading branch information
msupic committed Feb 12, 2024
1 parent 6dd0e2b commit 151cb85
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/main/java/org/example/UcpExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.example;

import oracle.ucp.jdbc.PoolDataSource;
import oracle.ucp.jdbc.PoolDataSourceFactory;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class UcpExample {
public static void main(String[] args) throws Exception {
PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource();
pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
pds.setURL("jdbc:oracle:thin:@localhost:1521/xepdb1");
pds.setUser("ucptest");
pds.setPassword("ucptest");
try (Connection conn = pds.getConnection()) {
try (Statement stmt = conn.createStatement()) {
ResultSet rs = stmt.executeQuery("SELECT table_name FROM all_tables");
while (rs.next()) {
System.out.println(rs.getString("table_name"));
}
}
}
}
}

0 comments on commit 151cb85

Please sign in to comment.