Java in the Database - Active Error

californiamandrillΛογισμικό & κατασκευή λογ/κού

13 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

95 εμφανίσεις

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

1

What’s New for Java in
Oracle Database 12c

Kuassi

Mensah

Director Product Management


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

3

The following is intended to outline our general product
direction. It is intended for information purposes only, and may
not be incorporated into any contract. It is not a commitment to
deliver any material, code, or functionality, and should not be
relied upon in making purchasing decisions. The development,
release, and timing of any features or functionality described for
Oracle

s products remains at the sole discretion of Oracle.

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

4

My Next Sessions


Oracle In
-
Database
MapReduce

(Hands
-
on lab)


7/24/13, 17:15


18:15, Room 411/412


Maximun

Application Availability with Oracle database 12c


7/25/13, 09:00


10:00, Room 429


Oracle In
-
Database
MapReduce
: When
Hadoop

Meets
Exadata


7/25/13, 12:00


13:00, Room 431



Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

5

Agenda


Support for Java Standards


Multitenant architecture & New SQL Data Types


Java Performance & Scalability


Java Availability


Global Data Services for Java


Security & Deprecated/
Desupported

Features



Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

6

Support for JDBC 4.1


Java SE 7, ojdbc7.jar, ucp.jar


setClientInfo
(), and
getClientInfo
()


getObject
()



try with resources



New methods in
java.sql.Connection






JDBC/UCP Support for JDK 7 and JDBC 4.1

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

7

Java in the Database


Multiple Java SE: JDK 6 & JDK 7; JNDI, Logging


Performance: Stored procedures & functions


Reuse skills and libraries


Integrate
Lucene
,
Solr
,
Hadoop

with the database


Image Transformation and Conversion (GIF, PNG, JPEG)


Parsers for various File Formats (txt, zip, xml, binary)


Calling
-
Out External Systems


HTTP Call
-
Out, JDBC Call
-
Out,
Web Services Call
-
Out


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

8

Java in the Database

Install JDK 7 at Database Creation Time



Run the following Perl script

perl

$ORACLE_HOME/
javavm
/install/update_javavm_binaries.pl 7


Relink

Oracle on Non
-
Windows platforms

cd

$ORACLE_HOME/
rdbms
/lib

make
-
f ins_rdbms.mk
ioracle


Proceed with database creation steps


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

9

Agenda


Java Standards


Multitenant architecture and New SQL Data Types


Java Performance & Scalability


Java Availability


Global Data Services for Java


Security& Deprecated/
Desupported

Features



Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

10

JDBC/UCP Support for Multitenant architecture


Transparent through Net Service


SET CONTAINER
<container>


Common pool across containers
thru UCP connection labeling
and callback

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

11


32K VARCHAR, NVARCHAR, and RAW


Invisible or Hidden Columns


Implicit Result Set


Auto
-
Increment Columns (IDENTITY columns)


PL/SQL Package Types as Parameter


JDBC Support for New SQL Data Types

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

12


VARCHAR2, NVARCHAR2, and RAW increased from 4,000 to
32,767 bytes


Java applications no longer need to switch to large objects
(LOBs) for data inferior to 32K in size


Indexes may be built on top of these columns


Pre
-
Requisites (DBA)


Set the
COMPATIBLE

initialization parameter to
12.0.0.0
.


Set the
MAX_STRING_SIZE

initialization parameter to
EXTENDED
.


Run the
rdbms
/admin/utl32k.sql
script.



32K VARCHAR NVARCHAR and RAW

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

13


Columns created with
INVISIBLE

SQL keyword


Invisible columns are not displayed during generic access
such as a
“SELECT * FROM table” or “DESCRIBE table”


JDBC furnishes
isColumnInvisible
()
to check whether a
column is invisible/hidden or not.

OracleResultSetMetaData

rsmd

=
(
OracleResultSetMetaData
)
rset.getMetaData
();

System.out.println
("Visibility:" +











rsmd.isColumnInvisible
(2));




Invisible or Hidden Columns

Ease of Upgrade

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

14


Problem to solve
: migrate Java applications from third
-
party RDBMS
that do not use
RefCursor
.


Implicit Results: retrieve the return of stored procedures (PL/SQL,
Java) directly, using
DBMS_SQL.RETURN_RESULT
.


Example of Stored Procedure using
dbms_sql.return_result
()

create or replace procedure
p_imres

as

result
sys_refcursor
;


begin



open result for select * from tab;



dbms_sql.return_result
(result);

end;



Implicit Result Set

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

15


New Oracle JDBC methods

getMoreResults
()
or

getMoreResults
(
int
)

The
int

parameter that can have one of the following values:

KEEP_CURRENT_RESULT
,
CLOSE_ALL_RESULTS
,
CLOSE_CURRENT_RESULT

getResultSet
():

iteratively retrieves each implicit result


The following foreign Java code will just work with Oracle


CallableStatement

cstmt

= null;


ResultSet

rs

= null;


cstmt

=
conn.prepareCall
(“{
call
p_imres
()
}”);


cstmt.execute
();


boolean

resultsAvailable

=
cstmt.getMoreResults
();






Implicit Result Set

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

16


Problem to Solve
: Reuse applications, built on foreign RDBMS,
that use auto
-
increment columns


The Oracle database 12
c

implements ANSI compliant
automatically incrementing columns using the SQL keyword
IDENTITY
.

CREATE TABLE t1 (c1 NUMBER GENERATED BY DEFAULT ON NULL AS
IDENTITY, c2 VARCHAR2(10));


No new JDBC API needed

JDBC Support for Auto
-
Increment Columns

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

17

PL/SQL Package Types as Parameter


Problem to Solve
: Access PL/SQL types as Java arrays without














creating PLSQL wrappers


Usage



type name
specified as


<package name>.<type name>
or


<schema name>.<package name>.<type name>

1) Create PLSQL types using
%ROWTYPE

CREATE OR REPLACE PACKAGE pack1 AS


TYPE
employee_rowtype_array

IS A TABLE OF
Employee%ROWTYPE
;

END;

/






Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

18

PL/SQL Package Types as Parameter

2) Obtain the rows as a

java.sql.Array

of
java.sql.Struct

CallableStatement

cstmt

=
connection.prepareCall
(







BEGIN SELECT * INTO :1 FROM EMPLOYEE; END;

);

cstmt.registerOutParameter
(1,
OracleTypes.ARRAY
,



PACK1.EMPLOYEE_ROWTYPE_ARRAY

);

cstmt.execute
();

Array
employeeArray

=
cstmt.getArray
(1);


This feature makes easier to fetch query results as Java Array or
Struct
, thereby simplifying Object
-
Relational mapping.





Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

19

Row Count per Array DML with JDBC


Java applications using Oracle JDBC drivers can now
retrieve the number of rows affected by each iteration of an
array DML statement (i.e., array INSERT, UPDATE,
DELETE).




int

rcount
[] =
stmt.executeBatch
();


Long Awaited

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

20

Agenda


Support for Java Standards


Multitetant

architecture and New SQL Data Types


Java Performance & Scalability


Java Availability


Global Data Services for Java


Security & Deprecated/
Desupported

Features



Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

21

New Performance and Scalability Features


New Memory Management


JDBC/UCP Support for Database Resident Connection Pool


Very Large Network Buffers (SDU)

Java Applications Performance & Scalability

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

22

Extreme Scalability with DRCP

Support Tens of Thousands of Concurrent Users

POC: 5000 users; DRCP pool size of 100

5000 x 4 MB +
DB Processes
100 x 4 MB +
5000 x 400 KB +
Session Memory
100 x 400 KB +
0
DRCP Broker
5000 x 35 KB
21 GB
Total
610 MB
Dedicated Servers
DRCP Servers

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

24


DRCP pools must be explicitly created, started and stopped by the
DBA using the
DBMS_CONNECTION_POOL
package.

sqlplus

/
nolog

connect / as
sysdba

execute
dbms_connection_pool.start_pool
();

...

execute DBMS_CONNECTION_POOL.CONFIGURE_POOL
(
session_cached_cursors
=>50);

...

execute
dbms_connection_pool.stop_pool
();






Configuring DRCP on RDBMS
-
Side

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

25

Very Large Network Buffers (SDU)


Controls SQL*Net packet size


Default: 8K


Max:
2MB (12c)
, 64K (11.2), 32K (pre
-
11.2)


Set in


sqlnet.ora: DEFAULT_SDU_SIZE


tnsnames.ora: SDU in address


Connect String


Larger SDU gives


Better Network throughput


Fewer system calls to send and receive data


Less CPU usage


system and user


Side
-
effect of larger SDU: Network buffers take up more memory


Where to configure?

Client

:
URL


sqlnet.ora
and/or


tnsnames.ora or LDAP

Server
: sqlnet.ora

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

26

Agenda


Support for Java Standards & New SQL types


Java Support for Multitenant Pluggable Databases


Java Performance & Scalability


Java Availability


Global Data Services for Java


Security & Deprecated/
Desupported

Features


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

27

Application Continuity for Java

Upon Database Outage Four Problems Confront Applications

1.
Hang

2.
Errors & Connection Handling

3.
Outcome of In
-
Flight Work

4.
Resubmission of In
-
Flight Work


More details in session “
Maximum Application Availability”


7/25/13, 09:00

10:00, Room 429


Problems to Solve

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

28

Application Continuity In Action


Call 1


Application


Proxy 1


Proxy 2

RAC
Database

Instance1

Instance2

Instance3


Call 2


Connection


Replay Context

Oracle JDBC Driver

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

29

Agenda


Support for Java Standards


Multitenant architecture and New SQL Data Types


Java Performance & Scalability


Java Availability


Global Data Services for Java


Security & Deprecated &
Desupported

Features


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

30

Databases in Replicated Environments

Challenges/ Requirements


No seamless way to efficiently
use all the databases



No automated load balancing
and fault tolerance

Primary

Active Standby

Active Standby

GoldenGate

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

31

Global Data Services

Global Data Services


Extends RAC
-
style service
failover,

load balancing

and manageability to
a set of replicated databases


Takes into account network latency,
replication lag, and service
placement policies


Achieve higher availability, improved
manageability and maximize
performance

Load Balancing and Service Failover for Replicated Databases

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

32

UCP Support for Global Data Services


Transparently supports existing Fast Connection Failover (FCF), Runtime
Load Balancing (RLB), Database Affinity


Specify global service name and region in connect URL


(DESCRIPTION=


(ADDRESS_LIST= (LOAD_BALANCE=ON) (FAILOVER=ON)







(ADDRESS=(
GDS_protocol_address_information
))


(ADDRESS=(
GDS_protocol_address_information
))


)

(CONNECT_DATA= (SERVICE_NAME=
global_service_name
)
(REGION=
region_name
)))


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

33

Agenda


Support for Java Standards


Multitenant architecture and New SQL Data Types


Java Performance & Scalability


Java Availability


Global Data Services for Java


Security & Deprecated/
Desupported

Features


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

34


JDBC now supports SHA
-
2 hashing algorithms:
SHA
-
256, SHA
-
384,
and SHA
-
512

prop.setProperty

(
OracleConnection.CONNECTION_PROPERTY_THIN_NET_CHECKSUM_TYPES
,

"( MD5, SHA1, SHA256, SHA384 or SHA512 )");

prop.setProperty

(
OracleConnection.CONNECTION_PROPERTY_THIN_NET_CHECKSUM_LEVEL
,
"REQUIRED");

Advanced Security Enhancements

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

35

Deprecated and de
-
supported features


Deprecated Features


Concrete types
oracle.sql.CLOB
,
oracle.sql.BLOB
,
oracle.sql.BFILE

oracle.sql.STRUCT
,
oracle.sql.ARRAY,oracle.sql.OPAQUE
:
use Java
and Oracle interfaces


Oracle style batching:
use Java Standard batching

pstmt.setInt
(1, 1234);
pstmt.setString
(2, “Product #1”);

pstmt.addBatch
();

int

[]
batchCount

=
pstmt.executeBatch
();


End to End metrics API:
use Java standard
setClientInfo
()


Desupported

Feature


JDK 5 is not supported in 12.1:
JDK 6 and JDK 7 supported


Implicit Connection Cache:
use UCP instead

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

36


Q & A


Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

37

Copyright

©

2013, Oracle and/or its affiliates. All rights reserved.

38