Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions java/AoJ/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ To run the sample file you will need a SQL database and corresponding JDBC drive
has been run with [Oracle Database 12c](http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html)
and [Oracle Database 12c JDBC](http://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html),
but it should work with any reasonably standard compliant SQL database and JDBC
driver. The sample file uses the scott/tiger schema available
[here](https://github.com/oracle/dotnet-db-samples/blob/master/schemas/scott.sql).
driver. The sample file uses the table 'emp' and 'dept'. So, you can create a user "testuser" and 'emp' and 'dept' tables using
[JDBCSampleData.sql](https://github.com/oracle/oracle-db-examples/blob/master/java/jdbc/BasicSamples/JDBCSampleData.sql).

Start the database and load ```scott.sql```. Edit ```com.oracle.adbaoverjdbc.test.FirstLight.java```
Start the database and make sure to create 'testuser' and needed tables using [JDBCSampleData.sql](https://github.com/oracle/oracle-db-examples/blob/master/java/jdbc/BasicSamples/JDBCSampleData.sql). Edit ```com.oracle.adbaoverjdbc.test.FirstLight.java```
and set the constant ```URL``` to an appropriate value. AoJ will pass this value
to ```java.sql.DriverManager.getSession```. If you are using a database other
than Oracle you should change the value of the constant ```TRIVIAL``` to some
Expand All @@ -67,7 +67,7 @@ very trivial ```SELECT``` query.
## Sample Code

The following test case should give you some idea of what AoJ can do. It should
run with any JDBC driver connecting to a database with the scott schema. This is
run with any JDBC driver connecting to a database with the 'testuser' schema. This is
the last test in ```com.oracle.adbaoverjdbc.test.FirstLight.java```. For an
introduction to ADBA see the
[JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf).
Expand Down
7 changes: 3 additions & 4 deletions java/AoJ/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ To run the sample file you will need a SQL database and corresponding JDBC drive
has been run with [Oracle Database 12c](http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html)
and [Oracle Database 12c JDBC](http://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html),
but it should work with any reasonably standard compliant SQL database and JDBC
driver. The sample file uses the scott/tiger schema available
[here](https://github.com/oracle/dotnet-db-samples/blob/master/schemas/scott.sql).
driver. The sample file uses the table 'emp' and 'dept'. So, you can create a user "testuser" and 'emp' and 'dept' tables using [JDBCSampleData.sql](https://github.com/oracle/oracle-db-examples/blob/master/java/jdbc/BasicSamples/JDBCSampleData.sql).

Start the database and load ```scott.sql```. Edit ```com.oracle.adbaoverjdbc.test.FirstLight.java```
Start the database and make sure to create 'testuser' and needed tables using [JDBCSampleData.sql](https://github.com/oracle/oracle-db-examples/blob/master/java/jdbc/BasicSamples/JDBCSampleData.sql). Edit ```com.oracle.adbaoverjdbc.test.FirstLight.java```
and set the constant ```URL``` to an appropriate value. AoJ will pass this value
to ```java.sql.DriverManager.getSession```. If you are using a database other
than Oracle you should change the value of the constant ```TRIVIAL``` to some
Expand All @@ -62,7 +61,7 @@ very trivial ```SELECT``` query.
## Sample Code

The following test case should give you some idea of what AoJ can do. It should
run with any JDBC driver connecting to a database with the scott schema. This is
run with any JDBC driver connecting to a database with the 'testuser' schema. This is
the last test in ```com.oracle.adbaoverjdbc.test.FirstLight.java```. For an
introduction to ADBA see the
[JavaOne 2017 presentation](http://www.oracle.com/technetwork/database/application-development/jdbc/con1491-3961036.pdf).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void testUser() {
assertEquals("USER", USER.name());
assertEquals(String.class, USER.range());
assertFalse(USER.validate(1234));
assertTrue(USER.validate("SCOTT"));
assertTrue(USER.validate("testuser"));
assertNull(USER.defaultValue());
assertFalse(USER.isSensitive());
}
Expand Down
4 changes: 2 additions & 2 deletions java/AoJ/test/com/oracle/adbaoverjdbc/test/TestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
* For example, this -D command line option would configure the database user:
* <br>
* <code>
* java -Dcom.oracle.adbaoverjdbc.test.TestConfig.USER=SCOTT ...
* java -Dcom.oracle.adbaoverjdbc.test.TestConfig.USER=testuser ...
* </code>
* <br>
* For convenience, configurable values can be identified by their short name,
* without the <em>com.oracle.adbaoverjdbc.test.TestConfig</em> prefix. For
* example, this -D command line option would also configure the database user:
* <br>
* <code>
* java -DUSER=SCOTT ...
* java -DUSER=testuser ...
* </code>
* <br>
* While convenient, potential collisions can arise if some other component
Expand Down
89 changes: 44 additions & 45 deletions java/jdbc/BasicSamples/JDBCSampleData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,20 @@ Rem
Rem MODIFIED (MM/DD/YY)
Rem nbsundar 04/06/18 - Created

Rem Create a new user "jdbcuser" that will be used in all JDBC code samples
Rem Create a new user "testuser" that will be used in all JDBC code samples
Rem Login as sysadmin before executing the script
CREATE USER jdbcuser IDENTIFIED BY jdbcuser123;
CREATE USER testuser IDENTIFIED BY testuser123;

Rem Grant connect and resource access to the new "jdbcuser"
Rem Grant connect and resource access to the new "testuser"
Rem so that the user can connect and create objects
GRANT CONNECT, RESOURCE TO jdbcuser;
GRANT CONNECT, RESOURCE TO testuser;

Rem Grant required access to the new "jdbcuser"
GRANT UNLIMITED TABLESPACE TO jdbcuser;
Rem Grant required access to the new "testuser"
GRANT UNLIMITED TABLESPACE TO testuser;

Rem Switch the current session to the new jdbcuser session
ALTER SESSION SET CURRENT_SCHEMA=jdbcuser;
Rem Switch the current session to the new testuser session
ALTER SESSION SET CURRENT_SCHEMA=testuser;

Rem Used in the SQLXMLSample.java code sample
CREATE TABLE SQLXML_JDBC_SAMPLE (DOCUMENT XMLTYPE, ID NUMBER);

Rem Used in the PLSQLSample.java code sample
CREATE TABLE PLSQL_JDBC_SAMPLE
(NUM NUMBER(4) NOT NULL,
NAME VARCHAR2(20) NOT NULL,
INSERTEDBY VARCHAR2(20));

Rem Used in LOBBasic.java code sample
CREATE TABLE LOB_JDBC_SAMPLE
(LOB_ID INT NOT NULL,
BLOB_DATA BLOB,
CLOB_DATA CLOB,
NCLOB_DATA NCLOB);

Rem Used in DateTimeStampSample.java code sample
CREATE TABLE EMP_DATE_JDBC_SAMPLE
(EMP_ID INTEGER PRIMARY KEY,
DATE_OF_BIRTH DATE,
DATE_OF_JOINING TIMESTAMP WITH LOCAL TIME ZONE,
DATE_OF_RESIGNATION TIMESTAMP WITH TIME ZONE,
DATE_OF_LEAVING TIMESTAMP);

Rem Used in JSONBasicDemo.java code sample
CREATE TABLE JSON_EMP_JDBC_SAMPLE
(EMP_ID RAW(16) NOT NULL PRIMARY KEY,
DATE_LOADED TIMESTAMP WITH TIME ZONE,
EMPLOYEE_DOCUMENT CLOB CONSTRAINT
ENSURE_JSON CHECK (EMPLOYEE_DOCUMENT IS JSON));

Rem Used in JSONBasicDemo.java code sample
INSERT INTO JSON_EMP_JDBC_SAMPLE VALUES (SYS_GUID(), SYSTIMESTAMP, '{"employee_number": 1, "employee_name": "John Doe", "salary": 2000}');
INSERT INTO JSON_EMP_JDBC_SAMPLE VALUES (SYS_GUID(), SYSTIMESTAMP, '{"employee_number": 2, "employee_name": "Jane Doe", "salary": 2010}');
INSERT INTO JSON_EMP_JDBC_SAMPLE VALUES (SYS_GUID(), SYSTIMESTAMP, '{"employee_number": 3, "employee_name": "John Smith", "salary": 3000, "sons": [{"name": "Angie"}, {"name": "Linda"}]}');
INSERT INTO JSON_EMP_JDBC_SAMPLE VALUES (SYS_GUID(), SYSTIMESTAMP, '{"employee_number": 3, "employee_name": "Jane Williams", "salary": 1000, "sons": [{"name": "Rosie"}]}');

Rem General DEPT table for other code samples
CREATE TABLE DEPT
(DEPTNO NUMBER(2) CONSTRAINT PK_DEPT PRIMARY KEY,
Expand Down Expand Up @@ -102,6 +65,42 @@ INSERT INTO EMP VALUES(7900,'JAMES','CLERK',7698,to_date('3-12-1981','dd-mm-yyyy
INSERT INTO EMP VALUES(7902,'FORD','ANALYST',7566,to_date('3-12-1981','dd-mm-yyyy'),3000,NULL,20);
INSERT INTO EMP VALUES(7934,'MILLER','CLERK',7782,to_date('23-1-1982','dd-mm-yyyy'),1300,NULL,10);

Rem Used in the SQLXMLSample.java code sample
CREATE TABLE SQLXML_JDBC_SAMPLE (DOCUMENT XMLTYPE, ID NUMBER);

Rem Used in the PLSQLSample.java code sample
CREATE TABLE PLSQL_JDBC_SAMPLE
(NUM NUMBER(4) NOT NULL,
NAME VARCHAR2(20) NOT NULL,
INSERTEDBY VARCHAR2(20));

Rem Used in LOBBasic.java code sample
CREATE TABLE LOB_JDBC_SAMPLE
(LOB_ID INT NOT NULL,
BLOB_DATA BLOB,
CLOB_DATA CLOB,
NCLOB_DATA NCLOB);

Rem Used in DateTimeStampSample.java code sample
CREATE TABLE EMP_DATE_JDBC_SAMPLE
(EMP_ID INTEGER PRIMARY KEY,
DATE_OF_BIRTH DATE,
DATE_OF_JOINING TIMESTAMP WITH LOCAL TIME ZONE,
DATE_OF_RESIGNATION TIMESTAMP WITH TIME ZONE,
DATE_OF_LEAVING TIMESTAMP);

Rem Used in JSONBasicDemo.java code sample
CREATE TABLE JSON_EMP_JDBC_SAMPLE
(EMP_ID RAW(16) NOT NULL PRIMARY KEY,
DATE_LOADED TIMESTAMP WITH TIME ZONE,
EMPLOYEE_DOCUMENT CLOB CONSTRAINT
ENSURE_JSON CHECK (EMPLOYEE_DOCUMENT IS JSON));

Rem Used in JSONBasicDemo.java code sample
INSERT INTO JSON_EMP_JDBC_SAMPLE VALUES (SYS_GUID(), SYSTIMESTAMP, '{"employee_number": 1, "employee_name": "John Doe", "salary": 2000}');
INSERT INTO JSON_EMP_JDBC_SAMPLE VALUES (SYS_GUID(), SYSTIMESTAMP, '{"employee_number": 2, "employee_name": "Jane Doe", "salary": 2010}');
INSERT INTO JSON_EMP_JDBC_SAMPLE VALUES (SYS_GUID(), SYSTIMESTAMP, '{"employee_number": 3, "employee_name": "John Smith", "salary": 3000, "sons": [{"name": "Angie"}, {"name": "Linda"}]}');
INSERT INTO JSON_EMP_JDBC_SAMPLE VALUES (SYS_GUID(), SYSTIMESTAMP, '{"employee_number": 3, "employee_name": "Jane Williams", "salary": 1000, "sons": [{"name": "Rosie"}]}');

Rem commit the changes to the database
commit;
Expand Down
6 changes: 3 additions & 3 deletions java/jdbc/BasicSamples/UCPMultiUsers.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class UCPMultiUsers {
static String user = DEFAULT_USER;
static String password = DEFAULT_PASSWORD;

// Modify these if user "scott" is locked in DB.
final static String USER2 = "scott";
final static String PASSWORD2 = "tiger";
// Modify these if user "testuser" is locked in DB.
final static String USER2 = "testuser";
final static String PASSWORD2 = "<your_db_password>";

public static void main(String args[]) throws Exception {
getRealUserPasswordUrl(args);
Expand Down
4 changes: 2 additions & 2 deletions java/ojvm/TrimLob.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public static void main (String args []) throws SQLException {

DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn =
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522/orcl", "scott",
"tiger");
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1522/orcl", "testuser",
"<your_db_password>");
}
long t0,t1;
/*
Expand Down
4 changes: 2 additions & 2 deletions java/ojvm/TrimLob.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REM replace scott/tiger with you database username/password
REM Create a table basic_lob_table
REM
connect scott/tiger;
connect testuser/<your_db_password>;
drop table basic_lob_table;
create table basic_lob_table (x varchar2 (30), b blob, c clob);
4 changes: 2 additions & 2 deletions java/ojvm/TrimLobSp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public class TrimLob

DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn =
DriverManager.getConnection("jdbc:oracle:thin:", "scott",
"tiger");
DriverManager.getConnection("jdbc:oracle:thin:", "testuser",
"<your_db_password>");
}
long t0,t1;
/*
Expand Down
2 changes: 1 addition & 1 deletion java/ojvm/Workers_OJVM.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class Workers

DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:thin:",
"scott", "tiger");
"testuser", "<your_db_password>");
System.out.println ("Running in JDK VM, outside the database!");
}

Expand Down
2 changes: 1 addition & 1 deletion java/ojvm/Workers_jdbc.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void main (String args []) throws SQLException {

DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
conn = DriverManager.getConnection("jdbc:oracle:thin:",
"scott", "tiger");
"testuser", "<your_db_password>");
System.out.println ("Running in JDK VM, outside the database!");
}

Expand Down