Enterprise J2ME Developing Mobile Java Applications [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Enterprise J2ME Developing Mobile Java Applications [Electronic resources] - نسخه متنی

Michael Juntao Yuan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید


14.2 The Oracle J2ME SQL SDK


The Oracle J2ME SDK (beta) enables mobile clients to access backend databases through the Oracle9i Mobile Application Server. It works on all J2ME profiles. There are only four classes in the oracle.wireless.me.sql package: DriverManager, Connection, Statement, and ResultSet. Their use is very similar to that of their JDBC counterparts. Those classes contain only very simple and lightweight methods. For example the query results can be retrieved only as string objects.

The SDK connects to a special gateway servlet, J2MEJDBC. The backend database URL and authentication information are stored in the gateway servlet's configuration file. Oracle runs a demo servlet for public testing. A simple example of database query using the SDK is shown in Listing 14.1.

Listing 14.1. Usage of the Oracle J2ME SDK



// The example is adopted from the
// Oracle SDK example
// The Oracle test gateway servlet URL.
// The backend DB is configured in the servlet.
DriverManager.init("http://iasw.oracle.com/ptg/j2mejdbc");
// Obtain a connection
Connection con = DriverManager.getConnection();
String sql = "select table_name from user_tables";
// Create a new Statement object
Statement stmt = con.createStatement();
// Get the ResultSet from the sql query
ResultSet rs = stmt.executeQuery(sql);
// Go to the next record
rs.next();
// Get a field in the record
System.out.println(rs.getString(1));



/ 204