|
1 | 1 |
|
2 | 2 | # Basic Samples in JDBC
|
3 | 3 |
|
4 |
| -"Basic Samples" is the first set of code samples aimed to show case some |
| 4 | +"Basic Samples" is the first set of code samples aimed to showcase some |
5 | 5 | of the basic operations and using some datatypes (LOB, SQLXML, DATE etc.,)
|
6 | 6 | The samples also contain Universal Connection Pool (UCP) functionalities to show
|
7 | 7 | how to harvest connections, label connections, how to use different timeouts, and
|
8 |
| -how to configure MBean to monitor UCP statistics etc., Read below for the |
9 |
| -description of the code samples. |
| 8 | +how to configure MBean to monitor UCP statistics etc., |
10 | 9 |
|
11 | 10 | # Creating DB User and Sample Data
|
12 | 11 | Before you run the code samples, we want you to create a new DB user and the necessary tables.
|
13 | 12 |
|
14 | 13 | Download [SQLDeveloper](http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/sqldev-downloads-42-3802334.html) or you can use SQLPLUS. Connect to your database and login as SYSADMIN.
|
15 |
| -Execute the script [JDBCSampleData.sql](https://github.com/oracle/oracle-db-examples/blob/basicsamples/java/jdbc/BasicSamples/JDBCSampleData.sql) that will create the new database user (JDBCUSER) and the |
| 14 | +Execute the script [JDBCSampleData.sql](https://github.com/oracle/oracle-db-examples/blob/basicsamples/java/jdbc/BasicSamples/JDBCSampleData.sql) that will create the new database user (jdbcuser) and the |
16 | 15 | tables necessary for the code samples.
|
17 | 16 |
|
18 | 17 | # Running Code Samples
|
19 |
| -There are three ways to run the sample. |
20 | 18 |
|
21 |
| -(a) Run each sample by passing the database URL and database user as the command-line |
| 19 | +(a) Download the [latest 12.2.0.1 ojdbc8.jar and ucp.jar](http://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html) and add these jars to the classpath. |
| 20 | + |
| 21 | +(b) Run each sample by passing the database URL and database user as the command-line |
22 | 22 | options. The password is read from console or standard input.
|
23 | 23 |
|
24 | 24 | ```java UCPMultiUsers -l <url> -u <user>```
|
25 | 25 |
|
26 | 26 | (b) Optionally, each sample has DEFAULT_URL, DEFAULT_USER, and DEFAULT_PASSWORD
|
27 | 27 | in the file. You can choose to update these values with your database credentials
|
28 |
| -and run the program. |
29 |
| - |
30 |
| -(c) If you don't update the defaults, then the program proceeds with the defaults |
| 28 | +and run the program. If you don't update the defaults, then the program proceeds with the defaults |
31 | 29 | but, will hit error when connecting as these are dummy values.
|
32 | 30 |
|
33 |
| -## DateTimeStampSample.java: |
34 |
| -This sample shows illustrates the usage of below Oracle column data types |
35 |
| -DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE. |
36 |
| -It uses the table 'EMP_DATE_JDBC_SAMPLE' which has dates as columns for |
37 |
| -all the insert, delete, and update operations. |
38 |
| - |
39 |
| -## JDBCUrlSample.java |
40 |
| -This sample shows how to use the easy connection URL, connection URL with connection descriptors, |
41 |
| -and using TNS alias to connect to the Oracle database. |
42 |
| - |
43 |
| -## JSONBasicSample.java |
44 |
| -This sample shows how to use some of the enhancements in JavaScript Object Notation (JSON) support |
45 |
| -for Oracle Database 12c Release 2 (12.2). |
46 |
| - |
47 |
| -## LobBasicSample.java |
48 |
| -This sample shows how to use different types of LOBs (Large Objects). |
49 |
| -It shows using BLOB, CLOB, and NLOB as datatypes. |
50 |
| - |
51 |
| -## PLSQLSample.java |
52 |
| -This sample demonstrates the usage of PL/SQL Stored Procedures and Functions in JDBC. |
53 |
| - |
54 |
| -## PreparedStatementBindingsSample.java |
55 |
| -This sample shows CRUD operations using the ```PreparedStatement``` with named bindings. |
56 |
| - |
57 |
| -## PreparedStatementSample.java |
58 |
| -This simple shows CRUD operations using the ```PreparedStatement``` object. |
59 |
| - |
60 |
| -## SQLXMLSample.java |
61 |
| -This sample shows how to create, insert, and query ``SQLXML`` values. |
62 |
| - |
63 |
| - ## StatementSample.java |
64 |
| - This sample shows CRUD operations using the Statement object. |
65 |
| - |
66 |
| - ## UCPBasic.java |
67 |
| - This sample shows simple steps of how JDBC applications use the Oracle Universal Connection Pool (UCP). |
68 |
| - |
69 |
| - ## UCPHarvesting.java |
70 |
| - This code sample shows how applications use the connection harvesting feature of UCP. |
71 |
| - |
72 |
| - ## UCPLabeling.java |
73 |
| - This sample shows how applications use the connection labeling feature of UCP. |
74 |
| - |
75 |
| - ## UCPManager.java |
76 |
| - This sample shows how applications use UCP manager's administration functions. |
77 |
| - |
78 |
| - ## UCPManagerMBean.java |
79 |
| - This sample shows how applications use UCP manager MBean's administration functions. |
80 |
| - |
81 |
| - ## UCPMaxConnReuse.java |
82 |
| - This sample shows how applications use the MaxConnectionReuseTime and MaxConnectionReuseCount features of UCP. |
83 |
| - |
84 |
| - ## UCPMultiUsers.java |
85 |
| - This sample shows how JDBC applications use UCPP to pool connections for different users. |
86 |
| - |
87 |
| - ## UCPTimeouts.java |
88 |
| -This sample shows key connection timeout features of UCP such as ConnectionWaitTimeout, InactiveConnectionTimeout, TimeToLiveConnectionTimeout, and AbandonedConnectionTimeout. |
| 31 | +```java UCPMultiUsers``` |
| 32 | + |
| 33 | +# Description of Code Samples |
| 34 | + |
| 35 | +* **DateTimeStampSample.java**:Shows the usage of Oracle column data types such as DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE. |
| 36 | +* **JDBCUrlSample.java**: Shows how to use the easy connection URL, connection URL with connection descriptors, and using TNS alias to connect to the Oracle database. |
| 37 | +* **JSONBasicSample.java**: Shows how to use some of the enhancements in JavaScript Object Notation (JSON) support for Oracle Database 12c Release 2 (12.2). |
| 38 | +* **LobBasicSample.java**: Shows how to use different types of LOBs (Large Objects), such as BLOB, CLOB, and NLOB as datatypes. |
| 39 | +* **PLSQLSample.java**: Demonstrates the usage of PL/SQL Stored Procedures and Functions in JDBC. |
| 40 | +* **PreparedStatementBindingsSample.java**: Shows CRUD operations using the ```PreparedStatement``` with named bindings. |
| 41 | +* **PreparedStatementSample.java**:Shows CRUD operations using the ```PreparedStatement``` object. |
| 42 | +* **SQLXMLSample.java**: Shows how to create, insert, and query ``SQLXML`` values. |
| 43 | +* **StatementSample.java**: Shows CRUD operations using the Statement object. |
| 44 | +* **UCPBasic.java**: Shows simple steps of how JDBC applications use the Oracle Universal Connection Pool (UCP). |
| 45 | +* **UCPHarvesting.java**: Shows how applications use the connection harvesting feature of UCP. |
| 46 | +* **UCPLabeling.java**: Shows how applications use the connection labeling feature of UCP. |
| 47 | +* **UCPManager.java**: Shows how applications use UCP manager's administration functions. |
| 48 | +* **UCPManagerMBean.java**: Shows how applications use UCP manager MBean's administration functions. |
| 49 | +* **UCPMaxConnReuse.java**: Shows how applications use the MaxConnectionReuseTime and MaxConnectionReuseCount features of UCP. |
| 50 | +* **UCPMultiUsers.java**: Shows how JDBC applications use UCPP to pool connections for different users. |
| 51 | +* **UCPTimeouts.java**: Shows key connection timeout features of UCP such as ConnectionWaitTimeout, InactiveConnectionTimeout, TimeToLiveConnectionTimeout, and AbandonedConnectionTimeout. |
89 | 52 |
|
90 | 53 |
|
91 | 54 |
|
0 commit comments