วันจันทร์, เมษายน 11, 2548

Using MySQL database with OC4J

From http://radio.weblogs.com/0135826/2004/03/29.html
? Copyright 2004 Debu Panda.


I received few requests to provide the steps to configure OC4J to use MySQL database. You can configure any database if you have a JDBC driver to be used with OC4J, however Oracle supports third-party databases like IBM DB2, Microsoft SQLServer, Sybase, etc. by using DataDirect JDBC drivers. The DataDirect drivers can be dowloaded from OTN (http://otn.oracle.com) for exclusive use with Oracle Application Server. In this blog entry, I will provide the steps to configure OC4J to use MySQL database. Please note that this note is for demonstration purpose only and is not officially supported by Oracle.

Assumption

This example assumes MySQL database is installed and configured. Let us assume that you have a name named EMP created in the Test database. Also you have downloaded the MySQL Connector/J JDBC driver from http://www.mysql.com/downloads/api-jdbc.html and readily available for use. Also I'm assuming that you are using OC4J 9.0.4 production or OC4J 10.0.3 Developer preview. You can download OC4J from http://otn.oracle.com/tech/java/oc4j/index.html.

Configure OC4J

1. Install JDBC Diver

You have to copy the JDBC driver library i.e. mysql-connector-java-3.0.11-stable-bin.jar to %OC4J_HOME%/j2ee/home/applib directory.

2. Create DataSource

Create the datasource entry for connecting to the MySQL database in the %OC4J_HOME%/j2ee/home/config/data-sources.xml as follows:

class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"

name="mysqlDS"

location="jdbc/mysqlCoreDS"

xa-location="jdbc/xa/mysqlXADS"

ejb-location="jdbc/mysqlDS"

connection-driver="com.mysql.jdbc.Driver"

username="root"

password="welcome"

url="jdbc:mysql://144.25.134.24/Test"

inactivity-timeout="30"

/>

3. Test DataSource

You have to restart OC4J before you can use the DataSource you created in the previous step. Here is a sample JSP that you can use to test the DataSource that you created in the previous step.

<%@ page import="java.sql.*, javax.naming.*, javax.sql.*" %>

<% try { InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("jdbc/mysqlDS");

Connection con = ds.getConnection(); Statement statement = con.createStatement();

ResultSet rset = statement.executeQuery("select * from emp"); %>

Test OC4J with MySQL DB



<table align="center" border="1">

<% while (rset.next()) { %>

<tr><td>

<%= rset.getInt(1) %>

<tbody><tr><td>

<%= rset.getString(2) %>
<td>

<% } statement.close();

con.close(); }

catch(Exception e)

{ out.print(e.getMessage()); }

%>

วันศุกร์, เมษายน 08, 2548

Firefox Shortcut

To use the keyboard shortcuts hold down CTRL and press one of the following:

TOpens a new tab and takes the focus to the new tab
OOpen Local File. This is one of the biggest changes from IE where both Ctrl-O and Ctrl-L opened a dialogue box for a URL.
LChanges focus to the Address bar
TabScrolls through the tabs from current window towards the right. Loops back to the first tab when rightmost tab is reached
1..0The numbers 1 to 0 takes the focus to Tab 1 to 10
NOpens a new window like IE
Wa tab or if there are no tabs, close the window
BOpen bookmark sidepanel
DBookmark current page
HBrings up the history dialogue box on the right. Useful if you closed a page accidentally and forgot the URL. Or to make sure your kids are not looking at pr0n
UShow page source
YOpen downloads window
KFocus goes to search bar

Some of the more common shortcuts just for the heck of it.

RRefresh current page
FFind in page
GFind Again (used in conjunction with Ctrl F)
JPage Info (same as properties in IE)
-Decrease font size
+Increase font size
SSave current page to disk
PPrint current page
ASelect All

A note about copy and pasting in Firefox; it is not integrated as closely as IE and the Office Suite for better or worse. For example copying the contents of a page directly in IE and pasting into Word for example keeps the formatting most of the time. Doing the same thing with Firefox results in plain text being copied over.

*edit An astute reader has pointed out another shortcut, "/" just the slash, not brackets which activates an incremental search; it will go to the first instance of the string that is typed in. Hit F3 to find again or hit ESC to cancel the search.

A more specific version of the incremental search is "'" which only finds links with the string entered.

*edit July 26th 2004 Thanks to August who pointed out yet a few more shortcuts as well as a small note - increasing the font size is the = and + key an would more correctly be CTRL =

F5 - refresh page
F6 - Same as CTRL-L, focus is taken to the address bar
CTRL Y - Open up the downloads window
CTRL K - Focus is taken to search bar
-----------------
Thanks to Achilles @www.tweakfactor.com

Firefox Tweak

Performance Settings

Quick and Dirty Settings
user_pref("network.http.pipelining", true);
user_pref("network.http.pipelining.firstrequest", true);
user_pref("network.http.pipelining.maxrequests", 8);
user_pref("nglayout.initialpaint.delay", 0);

Common to all configurations

These are the settings that seem to be common to all configuration files regardless of connection speed or computer speed with a couple of additions - plugin paths can be found with about:plugins and the bookmark menu delay is turned off.

user_pref("network.http.pipelining", true);
user_pref("network.http.proxy.pipelining", true);
user_pref("network.http.pipelining.maxrequests", 8);
user_pref("content.notify.backoffcount", 5);
user_pref("plugin.expose_full_path", true);
user_pref("ui.submenuDelay", 0);

Fast Computer Fast Connection

user_pref("content.interrupt.parsing", true);
user_pref("content.max.tokenizing.time", 2250000);
user_pref("content.notify.interval", 750000);
user_pref("content.notify.ontimer", true);
user_pref("content.switch.threshold", 750000);
user_pref("nglayout.initialpaint.delay", 0);
user_pref("network.http.max-connections", 48);
user_pref("network.http.max-connections-per-server", 16);
user_pref("network.http.max-persistent-connections-per-proxy", 16);
user_pref("network.http.max-persistent-connections-per-server", 8);
user_pref("browser.cache.memory.capacity", 65536);

A couple settings of note - Firefox is allocated 4096 KB of memory by default and in this configuration we give it roughly 65MB as denoted by the last line. This can be changed according to what is used.

Fast Computer, Slower Connection

This configuration is more suited to people without ultra fast connections. We are not talking about dial up connections but slower DSL / Cable connections.

user_pref("content.max.tokenizing.time", 2250000);
user_pref("content.notify.interval", 750000);
user_pref("content.notify.ontimer", true);
user_pref("content.switch.threshold", 750000);
user_pref("network.http.max-connections", 48);
user_pref("network.http.max-connections-per-server", 16);
user_pref("network.http.max-persistent-connections-per-proxy", 16);
user_pref("network.http.max-persistent-connections-per-server", 8);
user_pref("nglayout.initialpaint.delay", 0);
user_pref("browser.cache.memory.capacity", 65536);

Fast Computer, Slow Connection
user_pref("browser.xul.error_pages.enabled", true);
user_pref("content.interrupt.parsing", true);
user_pref("content.max.tokenizing.time", 3000000);
user_pref("content.maxtextrun", 8191);
user_pref("content.notify.interval", 750000);
user_pref("content.notify.ontimer", true);
user_pref("content.switch.threshold", 750000);
user_pref("network.http.max-connections", 32);
user_pref("network.http.max-connections-per-server", 8);
user_pref("network.http.max-persistent-connections-per-proxy", 8);
user_pref("network.http.max-persistent-connections-per-server", 4);
user_pref("nglayout.initialpaint.delay", 0);
user_pref("browser.cache.memory.capacity", 65536);

Slow Computer, Fast Connection
user_pref("content.max.tokenizing.time", 3000000);
user_pref("content.notify.backoffcount", 5);
user_pref("content.notify.interval", 1000000);
user_pref("content.notify.ontimer", true);
user_pref("content.switch.threshold", 1000000);
user_pref("content.maxtextrun", 4095);
user_pref("nglayout.initialpaint.delay", 1000);
user_pref("network.http.max-connections", 48);
user_pref("network.http.max-connections-per-server", 16);
user_pref("network.http.max-persistent-connections-per-proxy", 16);
user_pref("network.http.max-persistent-connections-per-server", 8);
user_pref("dom.disable_window_status_change", true);

One of the changes made for this particular configuration is the final line where the status bar is disabled for changing web pages to save processor time.

Slow Computer, Slow Connection

We have entered the doldrums of the dial-up user

user_pref("content.max.tokenizing.time", 2250000);
user_pref("content.notify.interval", 750000);
user_pref("content.notify.ontimer", true);
user_pref("content.switch.threshold", 750000);
user_pref("nglayout.initialpaint.delay", 750);
user_pref("network.http.max-connections", 32);
user_pref("network.http.max-connections-per-server", 8);
user_pref("network.http.max-persistent-connections-per-proxy", 8);
user_pref("network.http.max-persistent-connections-per-server", 4);
user_pref("dom.disable_window_status_change", true);