Source Code Cross Referenced for Trcycle.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » tables » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » JOnAS 4.8.6 » org.objectweb.jonas.jtests.tables 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         * 
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         * 
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         * 
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: Trcycle.java 4305 2004-03-08 13:57:43Z joaninh $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.tables;
027:
028:        import java.rmi.RemoteException;
029:        import java.sql.Connection;
030:        import java.sql.Statement;
031:        import javax.naming.NamingException;
032:        import org.objectweb.util.monolog.api.BasicLevel;
033:
034:        /**
035:         * Tables creation for the test beans/relation/rcycle.
036:         * (test about legacy CMP 2, cyles in relations, and relation between the same bean).
037:         */
038:
039:        public class Trcycle extends Tmanager {
040:
041:            /**
042:             * Entry point
043:             * @throws NamingException 
044:             * @throws RemoteException 
045:             */
046:            public static void init() throws NamingException, RemoteException {
047:                mgrInit();
048:                createTables();
049:            }
050:
051:            /**
052:             * create tables for the test beans/relation/rcycle (CMP2 legacy)
053:             * @throws RemoteException
054:             */
055:            private static void createTables() throws RemoteException {
056:
057:                // get connection
058:                Connection conn = null;
059:                try {
060:                    conn = dataSource.getConnection();
061:                } catch (Exception e) {
062:                    throw new RemoteException("Cannot get Connection");
063:                }
064:
065:                Statement stmt;
066:                // jt2_rcycle_person table associated to the bean Person
067:                String personTname = "JT2_RCYCLE_PERSON";
068:                // jt2_rcycle_j_par_child join table associated to the relation r-parents-children
069:                String jointTname = "JT2_RCYCLE_J_PAR_CHILD";
070:                try {
071:                    stmt = conn.createStatement();
072:                    stmt.execute("DROP TABLE " + personTname);
073:                    logger.log(BasicLevel.INFO, "Table " + personTname
074:                            + " dropped");
075:                    stmt.execute("DROP TABLE " + jointTname);
076:                    logger.log(BasicLevel.INFO, "Table " + jointTname
077:                            + " dropped");
078:                    stmt.close();
079:                } catch (Exception e) {
080:                    logger.log(BasicLevel.DEBUG, "Exception in drop Tables : "
081:                            + e);
082:                }
083:                try {
084:                    // jt2_rcycle_person table associated to the bean Person
085:                    stmt = conn.createStatement();
086:                    stmt
087:                            .execute("create table " + personTname
088:                                    + "(c_id integer not null primary key,"
089:                                    + " c_name varchar(40),"
090:                                    + " c_sex integer,"
091:                                    + " cfk_spouse integer,"
092:                                    + " cfk_guardian integer)");
093:                    stmt.execute("insert into " + personTname
094:                            + " values(1, 'Laurent Eric', 1, 2, null)");
095:                    stmt
096:                            .execute("insert into "
097:                                    + personTname
098:                                    + " values(2, 'Joanin-Laurent Helene', 2, 1, null)");
099:                    stmt.execute("insert into " + personTname
100:                            + " values(3, 'Laurent Guilhem', 1, null, 1)");
101:                    stmt.execute("insert into " + personTname
102:                            + " values(4, 'Laurent Malva', 2, null, 1)");
103:                    logger.log(BasicLevel.INFO, "Table " + personTname
104:                            + " created");
105:                    // jt2_rcycle_j_par_child join table associated to the relation r-parents-children
106:                    stmt.execute("create table " + jointTname
107:                            + "(cfk_parents integer,"
108:                            + " cfk_children integer)");
109:                    stmt.execute("insert into " + jointTname + " values(1, 3)");
110:                    stmt.execute("insert into " + jointTname + " values(1, 4)");
111:                    stmt.execute("insert into " + jointTname + " values(2, 3)");
112:                    stmt.execute("insert into " + jointTname + " values(2, 4)");
113:                    logger.log(BasicLevel.INFO, "Table " + jointTname
114:                            + " created");
115:                    stmt.close();
116:                    conn.close(); // release connection
117:                } catch (Exception e) {
118:                    logger.log(BasicLevel.ERROR, "Exception in create Table : "
119:                            + e);
120:                    throw new RemoteException("Exception in create Table : "
121:                            + e);
122:                }
123:            }
124:
125:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.