★ (transfer) J2ME learning notes (2)

xiaoxiao2021-03-06  17

This is a very simple example of helping classmates write, because I have no mobile devices in hand, and what simulator will not be used at that time. So just in the success of the debugging at this level. The database is used by SQL Anywhere, I feel that this is not bad. Because I have never been studied before, I think this is convenient. Don't buy melon again, how to use SQL Anywhere to speak in detail, I also have its Chinese documentation to study. / * * If you deploy jul9.dll and jul9_zh.jar on a WindowsCe device, you should install DJEODE * Establish Test.Lnk * 18 # "/ Memory Card / Insignia Solutions Jeoderuntime / evm.exe" * -djeode. Evm.console.local.keep = true * -djeode.evm.console.local.paging = true * -djul.library.dir = / UltraLite / lib * -cp /ultralite/tutorial;/ultralite/lib/jul9_zh.jar * Customer * // ** * @author * * * / import ianywhere.native_ultralite *;. import java.sql.SQLException; public class Customer {static Connection conn; public static void main (String args []) {try {Customer Cust = new customer (); cust.insert (); cust.select (); conn.close ();} catch (sqlexception e) {E.PrintStackTrace ();}} public customer () THROWS SQLEXCEPTION {DatabaseManager dbmgr = New DatabaseManager (); / * * UltraLite default drip database username and password. . .

I don't know if I don't know, I don't have this thing. * / String Parms = "UID = DBA" "; PWD = SQL" "; file_name = f: //j2me/tutcustomer.udb" "; Schema_File = f: //j2me/Tutcustomer.usm " "; CE_FILE = // UltraLite // Tutorial // Tutcustomer.udb " "; CE_SCHEMA = // UltraLite // Tutorial // Tutcustomer.usm "; / * * * * If you are deployed to the WindowsCe device, add two * ce_file = // UltraLite // tutorialialial // tutcustom = // UltraLite // tutorial // tutcustomer.usm * * At the desktop should be system this two lines No effect! Pay attention! * / Try {conn = dbMgr.openConnection (parms); System.out.println ( "connect to the database tutcustomer!");} Catch (SQLException econn) {if (econn.getErrorCode () == SQLCode.SQLE_ULTRALITE_DATABASE_NOT_FOUND) {/ / Judgment SQL error code, if there is no this database file, create conn = dbmgr.createdatabase (PARMS) according to the drip mode; system.out.println ("" Create a database according to the UltraLite mode provided ");} else {ECONN.PRINTSTACKTRACE ();}}} private void insert () throws sqlexception {Table T = conn.gettable ("Customer"); T.Open (); short id = t.schema.getColumnId ("ID"); Short fname = t.schema.getColumnid ("fnamee"); short lname = t.schema.getColumnId ("lnamee"); if (t.GetrowCount () == 0) {// Determine if there is data in the database, It is no longer added, not adding. . .

转载请注明原文地址:https://www.9cbs.com/read-44964.html

New Post(0)