Thursday, October 11, 2007

What is going on at Oracle Open World for Java in the database, JDBC, PHP, and Ruby on Rails?

1/ You can meet our developers at our demogrounds (JDBC, PHP, Ruby on Rails) in the database demoground.

2/ Here are the sessions, and hands-on labs that i am driving or involved with

Session ID: S290759 Session Title: Oracle JDBC Best Practices for Performance, Security, High Availability, and Scalability Room: Grand Ballroom A Date: 2007-11-12 Start Time: 11:00

Session ID: S292070 Session Title: The Way to the Web with PHP and Oracle Database Room: Yosemite Room A Date: 2007-11-12 Start Time: 12:30

Session ID: S292132 Session Title: Scale Your PHP Application to Tens of Thousands of Connections Room: HiltonContinental Parlor 7 & 8 Start Time: 1:45 PM

Session ID: S292073 Session Title: Web 2.0 Applications Hands-on Lab with PHP and Oracle Database Room: Continental Ballroom 4 Date: 2007-11-12 Start Time: 13:45

Session ID: S292211 Session Title: Hands-on Lab: Ruby on Rails with Oracle Database Track: Emerging Technologies Room: Continental Ballroom 4 Date: 2007-11-12 Start Time: 16:45

Session ID: S292213 Session Title: Digging Deeper into Dynamic Scripting Languages: Using Ruby on Rails with Oracle Database Room: Continental Parlor 7 & 8 Date: 2007-11-13 Start Time: 10:45

Session ID: S290758 Session Title: Java Stored Procedures or Java Middleware: Trade-offs, Techniques, and Tips from Oracle's Database and Middleware Teams Room: Continental Ballroom 6 Date: 2007-11-13 Start Time: 16:45

Session ID: S290761 Session Title: Behind the Scenes: Getting the Most from the New Java Virtual Machine in Oracle Database 11g Room: 308 Date: 2007-11-14 Start Time: 15:00

Session ID: S290760 Session Title: Oracle Database 11g Release 1 JDBC Pearls: JDBC 4.0, Advanced Security, Query Change Notification, Startup/Shutdown, and Much More Room: 307 Date: 2007-11-15 Start Time: 08:30

See you there

Friday, July 13, 2007

SOAP in SQL: Invoking external Web Services

What the Heck?

Have you ever felt the need to federate data from multiple sources, including Web services (e.g., stock price, scientific data, policy tables, tax tables, weather information)?

How would you invoke business operations implemented as external Web services, such as placing new orders, orders shipment, credit card payment transactions (and getting valid authorization numbers) from within the database?


Well, you need to turn your database into a Web Services Consumer.

Do you need to dive into the Web Services protocols, APIs and jargon beforehand?
No, magic JPublisher remove this pain from your neck! DBAs, PL/SQL bigots, and database developers in general don't need to know anything about WSDL, SOAP, UDDI, SOA to call a Web services from SQL or PL/SQL.


How does it work?

4 simple steps
1) Web Service enable your database: see the Web Services Callout utility guide
2) identify the target Web Services and save the location of the WSDL and the endpoint where
it is listening to requests. Examples: the Google Web Service is identified by its wsdl
WSDL: http://api.google.com/GoogleSearch.wsdl and is listening to requests @
Endpoint: http://api.google.com/search/beta2

A simple way to check that a Web service is up and listening to requests at the endpoint in
question is to direct your browser at the endpoint URL; you shoud, receive the following
message:

SOAP RPC Router
Sorry, I don't speak via HTTP GET- you have to use HTTP POST
to talk to me.


3) Ask JPublisher to generate everything needed to invoke the Web services from within the
database

C:\>jpub -u scott/tiger -sysuser=scott/tiger
-proxywsdl=http://api.google.com/GoogleSearch.wsdl
-proxyopts=tabfun,soap
-httpproxy=www-proxy.us.oracle.com:80
-endpoint=http://api.google.com/search/beta2 -dir=tmp


4) Invoke an operation (e.g., Spell Check) of the Web services directly from SQL

SQL> select jpub_plsql_wrapper.dospellingsuggestion( '', 'Nelson Mandelo')
as GOOGLE_Spell_Check_Web_Service
from dual;


That's it!

You can learn more in the following Oracle Database docs: JPublisher, the Java developers guide and also in chapter 16 of my book.

Have fun!

Thursday, May 24, 2007

Groovy, Ruby, PHP, Python: the revival of scripting languages

Scripting languages have been around for a long time but were regarded as only good for tactical quick-and-dirty applications. Then came the web and the need to add dynamic content to page templates through scriptlets (i.e. javascript). Then came the need to produce web pages directly from server-side (middle-tier and/or database).

To make this story short, 20+ millions web sites today are built using PHP, the most popular scripting language; add few millions for PERL, Python, and so on. Scripting languages got their "letter de nobless" and the rest is history!

Groovy, Ruby on Rails are the new generation of scripting languages. In chapter 5 of my book, i gave few examples of scripting languages running directly in the Oracle database including TCL (JACL), PYTHON (JYTHON), SCHEME and GROOVY. Note: these are just proof of concepts.

Even the Java community is embracing scriting languages through the proposed Java specification request 223 (particularly PHP) but The $1 Million question today is whether or not Ruby on Rails will overtake PHP and/or Java.

Just for fun, see this picture and this video.

Have Fun!

Thursday, May 03, 2007

Oracle Database at JavaOne

Hi,

For those attending JavaOne this year, i'll be available to talk Tuesday 05/8th (2:30 pm to 5:30 pm) and Wednesday 05/9th (2:00 to 4:30 pm ) at the Oracle Database demo pod within the Oracle quarter in the exhibition hall.
Stop by if you have interest or questions regarding Oracle JDBC, Java in the database, Oracle Database XE, and SQL Developer.
Fwiw, I'll be doing book signing Wed 05/9th at 4:30pm at the JavaOne book store.

See you

Sunday, April 22, 2007

Collaborate07, Application Express and .Net

I spent 4 days last week in the Mandalay Bay Casino-hotel in Las Vega (not gambling, as you would think!) but attending Collaborate07 a joint IOUG, OAUG and Quest International event.
It was a crowded event according to IT standards but there was in the same time an Entertainment industry convention with 100,000+ atendees; no other convention place can beat Las Vegas!
I gave a session on new JDBC and Java in the database featureas as part of Oracle Database 11g: What's new for Java, JDBC, PHP, OCI and .Net session.
I spent the rest of my stay at the exhibition floor demoing new JDBc and Java in the database.
I was sharing the same demo pod with my colleague Carl Backstrom (the APEX guy) and Christian Shay (the .Net guy). Even though we are all from Oracle it was the opportunity to better know the cool things Oracle is doing in the areas of Application Expres (APEX) and .Net.

I encourage you to visit their blogs http://carlback.blogspot.com/index.html, http://cshay.blogspot.com/ and play with their products.

Have fun, Kuassi

Saturday, April 07, 2007

Oracle Develop Coming to Your City

You probably recall the famous Alexandre Dumas's quote in my book "If you don't go to Lagardere, Lagardere will come to you"?

Well, Oracle Develop is coming to you in Seoul, Bangalore, Beijing, Munich, London, and Prague; check it out @
http://www.oracle.com/technology/events/develop2007/index.html

I'll be presenting:

  • Oracle JDBC: High-Availability, Load Balancing, Best Practices, and Roadmap
  • The PHP/Oracle Experience: Building for Scalability
  • Developing and Deplying Oracle and PHP (Hands-on Labs).

I'll be glad to meet you in person.

See you there, Kuassi

Monday, January 15, 2007

Is Your Java Application FailoverProof (i.e., RAC Aware)?

Developing and Deploying FailoverProof Java/JDBC Applications in RAC environment using Fast Connection Failover, TAF and Runtime Connection Load Balancing.

Why in the world should a Java developer care about failover and what does it mean to be failoverproof?
Well, failure is inevitable however, in mission critical (i.e., web) deployments, all applications including the Java ones must sustain resource manager (i.e., RDBMS) failure, or connection failure, or transaction failure without disrupting the service.

How exactly?
For the sake of simplicity, let's take a JDBC program. Best practices mandate that Java/JDBC programs capture exceptions and deal with these; here is a skeleton of a failoverproof program using Oracle JDBC in RAC environment:
...
try
{
conn = getConnection();
// do some work
} catch (SQLException e) {
handleSQLException(e); }
...
handleSQLException (SQLException e)
{
if (OracleConnectionCacheManager.isFatalConnectionError(e))
ConnRetry = true; // Fatal Connection error detected
}

Capturing SQL exceptons and re-trying to get a connection are all good JDBC programming so the burden is not really at the Java application level (it has to be somewhat portable), rather at the driver or framework level. Up to these (the driver, the OR Mapping framework, servlet engine, Java EE container) to furnish, under the covers, a failoverproof environment.

Do all drivers and Java frameworks are failoverproof?
You wish! The reality is that very few JDBC drivers or Java frameworks furnish true/reliable connection or transaction failover mechanisms.

From database access point of view, what does it take for a JDBC Driver or a Java framework to be failoverproof?
First of all, a JDBC driver or a Java EE ccontainer by itself cannot furnish a complete failoverproof environment, it more importantly requires the resource manager, in this case the RDBMS to be failoverproof as well. In the Oracle RDBMS case, instance/node failover as well as scalability is furnished by the RAC framework.

What is RAC?
An Oracle database is managed by a database instance which is made of a shared memory (a.k.a. SGA)and a set of database server processes. A database is usually accessed and managed by a single instance. However, an Oracle database can also be concurrently accessed and managed by multiple instances up to 64 nodes and beyond; this technology is known as Real Application Clusters (RAC).

How Does RAC Furnish Failover?
Starting with release 10g, RAC generates events that indicate the health or status of each RAC components including SERVICE, SERVICE_MEMBER,DATABASE, INSTANCE, NODE, ASM, and SRV_PRECONNECT.
The possible status are: UP, DOWN, NOT_RESTARTING, PRECONN_UP, PRECON_DOWN, and UNKNOWN.

Example of events can be: "Instance1 UP", "Node2 Down".

RAC furnishes failover by design in the sense that when a service/instance/node fails, a well written application can be redirected to the surviving node/instance provided these furnish the same service and proceed against the same database.

How Does JDBC Leverages RAC Failover?

The Oracle JDBC 10g drivers, more specifically it's connection cache (a.k.a. Implicit Connection Cache) leverages RAC by subscribing to the following events and status (as described in RAC documentation and in chapter 7 of my book):

  • Service Up: The connection pool starts establishing connections in small batches to the newly added service.
  • Instance (of Service) Up: The connection pool gradually releases idle connections associated with existing instances and reallocates these onto the new instance.
  • Instance (of Service) Down: The connections associated with theinstance are aborted and cleaned up, leaving the connection pool with sound and valid connections.
  • Node Down: The connections associated with the instance are aborted and cleaned up, leaving the connection pool with good connections.

But to be reliable, these events must be propagated to interested parties as fast as possible because the timeout mechanisms(tcp_keepalive, tcp_ip_interval, and so on) are unreliable and may take a long (tens of minutes) to indefinite time to be kick-in.
Orale furnishes ONS (Orale Notification Services) and Advanced Queue as publish/subscribe and predictable notification mechanisms which detects and propagates quasi-instantaneously (sub-seconds) those events to components that have subscribed to these mechanisms.

Setting up JDBC for Failover

  1. Set up a multinstance Oracle Database 10g RAC database (see RAC documentation).
  2. Virtualize the database host through a service name (see JDBC URL in chapter 7 of my book).
  3. Configure ONS on each RAC server node (see the RAC Administrator Guide or chapter 7 in my book).
  4. Configure ONS on each client node (10g Release 1) or use simpler remote subscription (10g Release 2). Ensure ons.jar file is in the CLASSPATH then programmatically set the ONS configuration string for remote ONS subscription at the data source level (unfortunately this cannot yet be set through system property): ods.setONSConfiguration("nodes=node1:4200,node2:4200"); The Java virtual machine (JVM) in which the JDBC driver is running must have oracle.ons.oraclehome set to point to ORACLE_HOME -Doracle.ons.oraclehome=
  5. Enable the Connection Cache and Fast Connection Failover through system property: -Doracle.jdbc.FastConnectionFailover = true Alternatively, the Connection Cache and Fast Connection Failover can be enabled programmatically using OracleDataSource properties: ods.setConnectionCachingEnabled(true); ods.setFastConnectionFailoverEnabled(true);

Oracle JDBC: Handling of DOWN events (Under the covers) Upon the notification of Service Down event, a worker thread (one per pool instance) processes the event in two passes:First pass: Connections are marked as down first, to efficiently disable bad connectionsSecond pass: Aborts and removes connections that are marked as downNote: active connections that may be in the middle of a transaction receive a SQLException instantly

Oracle JDBC: Hanlding of UP Events (under the covers)
A Service UP event initiates connections to be load balanced to all active RAC instances Connection creation depends on Listener’s placement of connections. Starting with 10g release 2,load balancing advisory events enabled Runtime Connection Load Balancing (covered in chapter 7 of my book).

Object-relational Mapping frameworks as well as any Java EE containers may either leverage Oracle JDBC (bypassing their own connection pool) or subscribe diretly to RAC events using the ONS APIs and processing these (i.e., handle connection retry). To my knowledge, only Oracle's Java EE containers (OC4J) has integrated Fast Connection Failover and ONS at datasource level.

How does Oracle JDBC Fast Connection Failover (FCF) compares with TAF?
Fast Connection Fail-over and TAF differ from each other in the followingways:

  1. Driver-type dependency: TAF is in fact a OCI failover mechanism exposed to Java through JDBC-OCI. FCF is driver-type independent (i.e., works for both JDBC-Thin and JDBC-OCI).
  2. Application-Level Connection Retries: FCF supports application-level connection retries (i.e., the application may retry the connection or rethrow the exception). TAF on the other hand retries connection transparently at the OCI/Net out of the control ofthe application or Java framework.
  3. Integration with the Connection Cache: FCF is integrated with the Implicit Connection Cache and invalidates failed connections automatically in the cache. TAF on the other hand works on a per-connection basis at the network level; it does not notify the connection cache of failures.
  4. Load Balancing: unlike TAF, FCF and runtime connection load balancing (RCLB) support UP event load-balancing of connections and runtime distribution of work across active RAC instances.
  5. Transaction Management: FCF automatically rolls back in-flight transations; TAF, on the other hand, requires the application to roll back the transaction and send an acknowledgment to TAF to proceed with the failover.
  6. TAF does not protect or fail-over codes that have server-side states such as Java or PL/SQL stored procedures; however, the application can register a callback function that will be called upon failure to reestablish the session states.

// register TAF callback function “cbk”

((OracleConnection) conn).registerTAFCallback(cbk,msg);

Voila, you now have a Java plateform with connection pool failover, on top of which you can code and deploy JDBC applications or Java EE components.

For more details, see chapter 7 of my book: http://db360.blogspot.com/2006/08/oracle-database-programming-using-java_01.html