Survey
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project
Mobile DB로 J2ME Program 관련 2001.5.26 홍재홍 제니시스기술 이사 [email protected] 모바일 데이터베이스 • 모바일 비즈니스 모바일 비즈니스는 다음과 같은 M-Commerce, B2E(business to Employee), Broadcast and Entertainment 등의 많은 분야에 적용 사례가 발표되고 있다. • 모바일 비즈니스의 의미는 필요한 정보를 어디에서나 얻을 수 있고 필요한 정보를 보낼 수 있다는 것이다. 기존의 기업 어플리케이션은 모두 데이터베이스 적용. 모바일 비즈니스의 정보는 보다 복잡해 질 것이고 이러한 정보의 형식은 데이터베이스화 될 것이다. 2 네트워크의 모든 곳에서 데이터를 관리한다. 새로운 인터넷 어플리케이션과 서비스 모바일 기기 digital services Sync mobile workforce 데이터베이스 Oracle, IBM DB/2, Sybase 모바일 네트워크 e-commerce Network Server Application Server 3 엔터프라이즈 시스템 모바일 데이터베이스의 필요성 • 데이터베이스의 필요성 데이터베이스는 어플리케이션의 개발을 쉽게 한다. 데이터베이스 엔진을 이용하여 복잡한 비즈니스 로직도 쉽게 구현할 수 있다. 어플리케이션의 변경, 추가 등을 용이하게 한다. • 모바일 환경 모바일 통신의 밴드는 제한적이며 항상 서버의 데이터베이스와 연결된 상태의 어플리케이션 설계는 바람직하지 않다. 모바일 장비는 대부분 배터리로 작동되며, 통신을 위하여 계속 대용량의 전력을 사용할 수 없다. 모바일 통신은 유선 통신에 비해 안정적이지 않다. 따라서 모바일 장비에 데이터베이스가 내장(Embedded)되어야 한다. 4 모바일 데이터베이스의 조건 • • • • • • 데이터베이스의 기본요건 Data Type, DDL, DML, multi-User 지원 등 작은 설치공간 모바일 디바이스는 경량급 디바이스 독립성 모바일 디바이스는 노트북에서부터 휴대전화, 전용단말의 수준까지 매우 다양하며 운영시스템 등이 매우 다양함. 데이터 동기화 지원 모바일 통신의 단절고려 데이터 베이스 간의 일치성 보장 개발과 관리의 편의성 SQL지원, 표준지원 관리의 용이성 자바 개발도구와 연동 기타 다양한 객체지원(BLOB, CLOB,data type Class, Procedure, Java Method) 5 모바일 데이터베이스의 종류 • • • • 제품 공급사 IBM(DB2 Everyplace, CloudScape), PointBase(Pointbase Server), Sybase(SQL Anywhere), ObjectDesign(Object Pro) Microsoft(Personal SQLServer), Inprise(JDataStore) 언어 기반 Java Base – PointBase, CloudScape C base - Others 규모 종류 Device Level – Mobile Phone, Low-end PDA, 산업기기, 가전기기 등(ROM), 100~200K Mobile station – High-end PDA, Notebook, Desktop 등 200k 이상 사용자 Single User - 6 Java Database vs. Native Database Application JDBC Application Java Database JDBC Oracle IBM DB2 Sybase MS SQL Srvr JVM JVM OS OS 100% Pure Java Database Native Database 7 자바기반의 모바일 데이터베이스 Multi-User, Multi Connection Multi-User, Multi Connection (Embedded) Single-User, High-end Device (Embedded) Single-User Low-end Device (Embedded) Profile Profile Java2 Platform Enterprise Edition Profile Java2 Platform Standard Edition TV Profile Web Phone Profile Car Profile Handheld Profile Wireless Profile Personal Profile Smart Card Profile Java 2 Micro Edition HotSpot Java Language JVM 8 KVM Card VM Benefits of Java • • • • • 이식성(Portability) “One compile runs on all Java platforms” 생산성(Productivity) Object Architecture enables flexible, modular design with components implemented on an as-needed basis Objects may be easily modified or reused 품질과 안정성(Quality and stability) Single development environment reduces porting errors and limitations Elimination of pointers reduces coding errors 어플리케이션 Well over one million Java developers More apps = more value 보안 Java byte code enables safe downloads 9 Java 기반 Database 추가 검토사항 • • • • 사용자의 비용 절감 자동화된 관리 시스템 자원 요구의 최소화 기존 시스템에 대한 투자 보전 기존의 어플리케이션과 데이터베이스와 연결 (Oracle, IBM DB2, Sybase, MS SQL Server) 산업표준의 충실한 준수 품질과 신뢰성 확보 100% Pure Java로 개발 모든 플랫폼에 대한 단일 개발환경 구현 SQL지원 IDC: 65%의 자바 어플리케이션에 데이터베이스필요 SQL은 비즈니스 어플리케이션의 표준 대부분의 장비는 엔터프라이즈 e-commerce와 접속 10 Java 기반 Database 추가적 점검사항 • JDBC지원 JDBC 는 업계의 표준 트랜젝션의 무결성 유지 Native JDBC 인터페이스 Type 4 JDBC driver – Optimized for native JDBC (중간 변환 단계 이용 없음) – 100% Pure Java implementation – Support for JDBC version 1 and version 2 • 광범위한 객체지원 데이터 형식(Data Type) – “BLOB” 및 “CLOB” 형식의 컬럼 저장 – 자마 클래스의 영속적인 저장 루틴(Routines) – 자바 메쏘드로 구현된 스토어드 프로시져(Stored procedures)와 펑션(functions) 11 내장형 데이터베이스(Embeded Database) 핵심기술 • 효율적인 다운로딩을 위한 작은 설치공간 • 자바 클래스를 포함한 객체 지원 • 데이터베이스 동기화 12 효율적인 다운로딩을 위한 작은 설치공간 • 동적 저장공간 아키텍쳐(Dynamic footprint architecture) 모듈(class files)은 실행 중에 필요한 경우에만 메모리에 로드 된다. 최소한의 설치공간을 위하여 계속적으로 클레스를 추가하거나 삭제한다. Synch. Synch. Database kernel Database kernel Memory Disk 13 효율적인 다운로딩을 위한 작은 설치공간 • C-기반의 어플리케이션 C 와 C++ 같은 언어를 사용한 어플리케이션은 기능의 일부만 이용할 경우에도 모든 어플리케이션을 메모리에 할당한다. Replic Create Tables Replic Create Tables Security Transactions Security Transactions Multi User Update 데이터 Multi User Update 데이터 Objects Read Only Objects Read Only Memory Disk 14 자바 클래스를 포함한 객체 지원 • employee Java Classes as data Types Column of type BLOB – Java classes (e.g., example.class) stored as a field in the table – Support for serializable Java classes insert into table hr_roster (employee) values (Jeff.class); Object-relational mapping – Object attributes mapped Name Loc Hobbies Person.class to individual columns – Enables manipulation of objects using SQL Jeff.class (serialized Name=Jeff Java class) Loc=San Francisco Hobbies=Tennis 15 자바 클래스를 포함한 객체 지원 Java Methods as SQL Functions (1) Define Java class and method public class y2kdataconversion { public java.sql.date y2kdate(String p_Date) { … return l_Date; } … } • (2) Create SQL function based on Java method Create Function DateConversion(in Varchar(40)) Returns Date Language Java External Name “com.apps.y2kdataconversion::y2kdate” Parameter Style SQL … Insert into SomeTable Values(DateConversion(‘220299’), …) 16 자바 클래스를 포함한 객체 지원 Java Methods as SQL Procedures (1) Define Java class and method public class employee { public void incSalary(String p_Name, jdbcInOutFloatWrapper p_Salary) {…} … } (2) Create SQL procedure based on Java method Create Procedure IncreaseSalary(in Varchar(40), inout Decimal(5,2)) Language Java External Name “com.apps.employee::incSalary” Parameter Style SQL … CALL IncreaseSalary(‘Bill Jones’, 5432.22) 17 데이터베이스 동기화 • PointBased의 “UniSync synchronization (예) Publish - Subscribe Model Topology Options Synchronization - Snapshot Synchronization - Point-Update Schema synchronization Validation Conflict Detection and Resolution 18 Publish and Subscribe Model Publisher Subscriber Computer Computer Database(s) Database(s) • Publication(s) • Subscription(s) TCP/I P HTTP Multiple Tables or Single Table 19 Topology Options Publisher Subscribers Publisher Subscriber Publisher Subscribers Peer-to-peer Hub and spoke 20 Synchronization - Snapshot Publisher Subscriber Computer Computer Database Database Publication Subscription Site = ‘CA’ Filtering • Copy entire publication between systems 21 Synchronization - Point Update Publisher Subscriber Computer Computer Database Database Publication Subscription • Copy updates, inserts, or deletions made to publication 22 Schema synchronization • 시스템간의 스키마 변경 동기화 • 어플리케이션/데이터베이스의 업데이트 자동구현 어플리케이션 변경에 따른 데이터베이스 관리 비용을 줄인다. Add/drop table Publication Add/drop column Subscription New table Synchronize Schema Changes Subscriber Publisher 23 Schema synchronization • 명령은 API나 Console을 이용 Add/drop table, Add/drop column 명령은 publisher에서 subscriber로 배포됨. * Add-database API AdddataSource( syncCatalog sc, String 데이터Source) throws Exception { rowset데이터Source rds = new rowsetdataSource(dataSource,m_URL); Properties l_props = new Properties(); l_props.put("user", m_User); l_props.put("password",m_Password); l_props.put("driver",m_Driver); rds.setProperties(l_props); sc.adddataSource(rds.toRowSet()); } 24 Synchronization Validation 동기화 세션 을 초기화 하기 전에 분산된 데이터베이스들이 일치된(consistent) 상태인지를 검증 어플리케이션이 변경을 감지하고 적절한 대응을 할 수 있도록 한다. 역시 Synch Console 이나 Synch API을 통하여 초기화 시킨다. Publisher Subscriber - Subscription name - Subscription set up - Mapping with publication - Point update only after snapshot - Publication name - Publication set up - Mapping with subscription - Point update only after snapshot 25 Conflict Detection and Resolution • publisher 와 subscriber에서 같은 데이터에 대한 변경을 하였을 때 충돌이 일어남. • 충돌감지(Conflict detection): 감지만 수행 Enabled through .ini file setting Logs conflicts in PointBase table on the publisher Available for later audit and reference Values on publisher and subscriber are left “as-is” • 충돌해결 (Conflict resolution): 충돌을 감지하고 적절한 값을 결정하기 위한 업무 규칙을 적용함 Enabled through .ini file setting Standard resolution schemes: hub wins, poke wins Custom resolution schemes: defined by developer – Examples: increment/decrement, concatenate Defined at column, table, or publication level 26 모바일 데이터베이스 Sample Application • 제목 : Mobile Service Force Management (After Service Report) • 구성 : Hub: PC - windows 2000 Spoke : PDA -Wince , PDA -PalmOS • 개발 Focus : Personal Java 기반의 program(Wince) kvm 기반의 program(PalmOS) • DB : Wince (JVM 기반의 PointBase -Mobile Edition) PalmOS (KVM 기반의 PointBase- Device Edition & JVM 기반의 PointBase-Mobile Edition) 27 시험구현 범위 Desktop Enterprise Database System ( oracle 8i) UniSyn c Middle Tier Application Servers Mobile Clients and Devices NoteBook PointBase Network Server DB UniSyn c Palm PointBase MobileEdition or Device Editon Kada(personal Java) or KVM 28 Wince Pointbase Mobile Edition Personal Java (JVM) Database Tables( ER Diagram) 29 Mobile Service Force Management – 시나리오 • 업무 진행 시나리오 -오전에 Enterprise DB와 Mobile Edition이 온라인 상으로 연결 - LOGIN (자신의 ID로 login 한다.) - Enterprise DB와 Mobile Edition과 Table 동기화 된다. Enterprise schema 와 데이터의 일부를 Mobile Edition 에 자동 삽입한다.(자신의 업무를 받는다.) - 엔지니어는 자신에게 부여된 업무를 파악한다. - 저장된 DB를 통해 고객의 정보 검색 및 위치를 파악한다. - 업무를 수행하고 자신의 DB에 저장한다. - 업무 수행 완료 후 곧바로 부분 동기화 작업한다.(point update) - 회사에 돌아온 후 전체 동기화 시킨다(SnapShot) 30 Engineer Assignments Table • Engineer Assignment Enterprise DataBase EnterPrise DB와 온라인상에서 로그인 하면 본인의 업무만 ASSIGNMENTS_TBL 저장 (Engineer.Eng_ID=ASSIGNMENTS_TBL.Eng_ID) Mobile Database 31 고객의 위치 정보(1) • 고객의 자세한 위치정보 Enterprise DataBase 고객의 자세한 위치 데이터 (ASSIGNMENTS_TBL. ASSN_ID =DIR_TBL.ASSN_ID) Mobile Database 32 고객의 위치 정보(2) • 고객의 위치 이미지 Enterprise DataBase 고객의 위치 정보에 대한 이미지 (IMAGE_TBL. IMAGE_ID=ASSIGNMENTS_TBL. ASSN_ITEM_ID) Mobile Database 33 Customer History Management • 고객 HISTORY 정보 Enterprise DataBase 1.고객의 문제점에 대한 History 정보 2.출장 시 고객의 문제점에 대한 도움 정보 3.여러 가지 정보 제공 가능…. Mobile Database 34 The management of business Logic • 화면 구성 로그인 화면 고객 위치 데이터 화면 본인 업무 검색 고객 위치 이미지 화면 업무수행 후 저장 업무 수행 후 동기화 (부분 동기화) 복귀 후 동기화 (전체 동기화) 35 데이터 베이스 생성(Mobile Edition) • Mobile Edition Driver : com.pointbase.jdbc.jdbcUniversalDriver URL: jdbc:pointbase:database_name[,flag] [,UserName, Password] flag : new 하면 데이터베이스를 새로 생성 [,flag] 없으면 기존 데이터 베이스 연결 • DriverManager.getConnection(“jdbc:pointbase:m ydb,new,”admin”,”java”) 36 데이터 베이스 생성(Embedded Server) • Embedded Server Driver : com.pointbase.jdbc.jdbcUniversalDriver URL: jdbc:pointbase://embedded/database_name[,fla g] [,UserName, Password] flag : new 하면 데이터베이스를 새로 생성 [,flag] 없으면 기존 데이터 베이스 연결 • DriverManager.getConnection(“jdbc:pointbase:// embedded/mydb,new,”admin”,”java”) 37 데이터 베이스 생성(Network Server) • Network Server Driver : com.pointbase.jdbc.jdbcUniversalDriver URL: jdbc:pointbase://host_name/database_name[,flag ] [,UserName, Password] flag : new 하면 데이터베이스를 새로 생성 [,flag] 없으면 기존 데이터 베이스 연결 • DriverManager.getConnection(“jdbc:pointbase:// server1/mydb,new,”admin”,”java”) 38 프로그램 소스(데이터베이스 생성) void logon( String databaseName ) throws SQLException { try { String dburl = "jdbc:pointbase:" + databaseName + ",new"; String driver = "com.pointbase.jdbc.jdbcUniversalDriver"; Class.forName( driver ).newInstance(); m_con = DriverManager.getConnection ( dburl, "public", "public" ); m_stmt = m_con.createStatement(); } catch( SQLException sqlEx ) { throw sqlEx; } catch( Exception e ) { System.err.println( e ); } } 39 프로그램 소스(테이블 생성) void create() throws SQLException { final String create_sql = "CREATE TABLE engineer ( eng_id CHAR(6) NOT NULL, eng_name VARCHAR(15) NULL, eng_dept VARCHAR(20) NULL ); m_stmt.executeUpdate( create_sql ); } 40 프로그램 소스(데이터 입력) void insert() throws SQLException { final String insert_sql = "INSERT INTO engneer VALUES ( ?,?,?))"; PreparedStatement pstmt = m_con.prepareStatement( insert_sql ); if( pstmt != null ) { for( int i=0; i<data.length; i++ ) { pstmt.setString( 1, eng_id] ); pstmt.setString( 2, eng_name); pstmt.setString( 3, eng_dept ); pstmt.execute(); } } } 41 프로그램 소스(데이터 검색) void select() throws SQLException { final String select_sql = "SELECT * FROM Engineer"; ResultSet rs = m_stmt.executeQuery( select_sql ); ResultSetMetaData rsmd = rs.getMetaData(); String strColName = rsmd.getColumnName( 1 ); while( rs.next() ) { String strTitle = rs.getString( 1 ); System.out.println( strTitle ); } } 42 Unicync Engine Server 생성(1) • Enterprise Database와 서로 동기화를 시키기 위해서는 서로 연결할 수 있는 엔진을 생성 한다. replServerEngine ue = new replServerEngine( conn, true ); • 엔진에 Catalog를 얻어온다. (Catalog란 테이블을 전체 리스트를 포함한다.) syncCatalog sc = ue.getCatalog(); 43 Unicync Engine Server 생성(2) 동기화를 위한 Site를 생성한다. TCP,HTTP 두가지 방법을 통한 동기화를 할수 있다. addSite(sc, m_hubsite, true, true); rowsetSite rss = new rowsetSite(); rss.setName(siteName); if (isThisSite) { rss.setType(rowsetSite.THIS_SITE); } else { if (isHub) rss.setType(rowsetSite.HUB_SITE); else rss.setType(rowsetSite.SPOKE_SITE); } 44 Unicync Engine Server 생성(3) //tcp rowsetSiteProtocol rssp = new rowsetSiteProtocol(m_ThisSiteURL); rssp.addProperty("format","com.pointbase.unisync.fmt.ObjectFormatter") ; //http rowsetSiteProtocol rssp2 = new rowsetSiteProtocol ("http://harsha:80/servlets/com.pointbase.unisync.comm.httpProxyServlet .HttpProxyServlet"); rssp2.addProperty("format","com.pointbase.unisync.fmt.Objectformatter" ); rssp2.addProperty("destination","localhost:2000"); rss.addProtocol(rssp); rss.addProtocol(rssp2); sc.addSyncSite(rss.toRowSet()); 45 Unicync Engine Server 생성(4) • 데이터 소스를 생성한다. • addDataSource(sc, m_dataSource); rowsetDataSource rds = new rowsetDataSource(dataSource, m_URL); Properties l_props = new Properties(); l_props.put("user", m_User); l_props.put("password",m_Password); l_props.put("driver",m_Driver); rds.setProperties(l_props); sc.addDataSource(rds.toRowSet()); 46 Unicync Engine Server 생성(5) Publication 를 생성한다 rowsetPublication rsp = addPublication(sc,m_PubName, m_dataSource); rowsetPublicationDataItem rpdi = new rowsetPublicationDataItem(); rpdi.setName("PUBLIC.MOVIE"); rowsetPublicationDataField rpdf = new rowsetPublicationDataField(); rpdf.setName("MOVIE_NUMBER"); rpdf.setType(Types.INTEGER); rpdf.setSize(10); rpdf.setScale(0); rpdi.addDataField(rpdf); rowsetPublication rp = new rowsetPublication(); rp.setName(m_PubName); rp.setDataSourceName(dataSource); rp.addDataItem(rpdi1); sc.addPublication(rp.toRowSet()); 47 Unicync Engine 생성(1) Sync Engine 생성 (Hub는 replServerEngine) replEngine re = new replEngine( conn, true ); syncCatalog sc = re.getCatalog(); // add Hub site and this site(spoke1) addSite(sc, m_SpokeSite, false, true); //add Spoke site and this site(hub1) addSite(sc, m_HubSite, true, false); // add data source to catalog addDataSource(sc, m_DataSource); //open new session syncSession ss = null; 48 Unicync Engine(2) Hub Site Session을 열고 SubScription을 생성한다. try { ss = re.openSessionWith(m_HubSite, m_User, m_Password); } catch (syncException se) { System.exit(0); } String[] l_pubnames = ss.getAllPublicationNames(); rowsetPublication l_Pub = new rowsetPublication(ss.getPublication(l_pubnames[0])); addSubscription(sc, m_SubName, l_Pub); ss.subscribe(m_SubName); ss.close(); re.shutdown(0); 49 Unicync Engine 생성(3) Spoke site This Site 그리고 Hub Site는 Hub Site 지정 addSite(syncCatalog sc,String Site, boolean isHub, boolean isThisSite) throws Exception { rowsetSite rss = new rowsetSite(); if (isThisSite) { rss.setName(Site); rss.setType(rowsetSite.THIS_SITE); } else { rss.setName(Site); if(isHub) rss.setType(rowsetSite.HUB_SITE); else rss.setType(rowsetSite.SPOKE_SITE); } 50 Unicync Engine 생성(4) subScription 생성 private static void addSubscription( syncCatalog sc, String subName, rowsetPublication rsp ) throws Exception { rowsetSubscription rsub = new rowsetSubscription (subName, m_DataSource, rsp); sc.addSubscription(rsub.toRowSet()); } 51 세션의 동기화 • 서로 동기화를 맞춘다. 1. RowSet 전체를 동기화 한다. ss.getSnapshot("Sub1"); ss.putSnapshot(“sub1"); 2.RowSet point 만 동기화 한다. while (true) { i++; ss.putPointUpdate("Sub1"); ss.getPointUpdate("Sub1"); } 52 실행 화면 로그인 화면 53 실행 화면 전체 메뉴 화면 54 실행 화면 본인 업무 검색 55 실행 화면 고객 위치 정보 상세 설명 56 실행 화면 고객 위치 이미지 정보 57 실행 화면 업무 기록 화면 58 실행 화면 업무 데이터의 동기화 59 참고 사이트 제니시스 기술 - http://www.genesis.co.kr PointBase - http://www.pointbase.com 기술 문의 홍재홍 [email protected] 유제정 [email protected] 유호성 [email protected] 이혁주 [email protected] 이강종 [email protected] 60