Source Code Cross Referenced for RunningVersion.java in  » Forum » mvnforum-1.1 » org » mvnforum » phpbb2mvnforum » 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 » Forum » mvnforum 1.1 » org.mvnforum.phpbb2mvnforum 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /cvsroot/mvnforum/mvnforum/contrib/phpbb2mvnforum/src/org/mvnforum/phpbb2mvnforum/RunningVersion.java,v 1.5 2007/12/18 04:58:45 minhnn Exp $
003:         * $Author: minhnn $
004:         * $Revision: 1.5 $
005:         * $Date: 2007/12/18 04:58:45 $
006:         *
007:         * ====================================================================
008:         *
009:         * Copyright (C) 2002-2007 by MyVietnam.net
010:         *
011:         * All copyright notices regarding mvnForum MUST remain 
012:         * intact in the scripts and in the outputted HTML.
013:         * The "powered by" text/logo with a link back to
014:         * http://www.mvnForum.com and http://www.MyVietnam.net in 
015:         * the footer of the pages MUST remain visible when the pages
016:         * are viewed on the internet or intranet.
017:         *
018:         * This program is free software; you can redistribute it and/or modify
019:         * it under the terms of the GNU General Public License as published by
020:         * the Free Software Foundation; either version 2 of the License, or
021:         * any later version.
022:         *
023:         * This program is distributed in the hope that it will be useful,
024:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
025:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
026:         * GNU General Public License for more details.
027:         *
028:         * You should have received a copy of the GNU General Public License
029:         * along with this program; if not, write to the Free Software
030:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
031:         *
032:         * Support can be obtained from support forums at:
033:         * http://www.mvnForum.com/mvnforum/index
034:         *
035:         * Correspondence and Marketing Questions can be sent to:
036:         * info at MyVietnam net
037:         *
038:         * @author: 
039:         */
040:        package org.mvnforum.phpbb2mvnforum;
041:
042:        import java.io.File;
043:        import java.io.FileOutputStream;
044:        import java.io.PrintStream;
045:        import java.sql.*;
046:
047:        public class RunningVersion {
048:
049:            Connection phpbb_c = null;
050:
051:            Connection mvnforum_c = null;
052:
053:            PrintStream sqlout = null;
054:
055:            /**
056:             * @param phphost
057:             * @param phpdb
058:             * @param phpuser
059:             * @param phppass
060:             * @param mvnhost
061:             * @param mvndb
062:             * @param mvnuser
063:             * @param mvnpass
064:             * @param ostream
065:             */
066:            public RunningVersion(String phphost, String phpdb, String phpuser,
067:                    String phppass, String mvnhost, String mvndb,
068:                    String mvnuser, String mvnpass, PrintStream ostream)
069:                    throws Exception {
070:
071:                if ((phphost == null) || (phpdb == null) || (phpuser == null)
072:                        || (phppass == null)) {
073:                    throw new Exception(
074:                            "php database details were not provided : phphost="
075:                                    + phphost + " phpdb=" + phpdb + "phpuser="
076:                                    + phpuser + "phppass=" + phppass);
077:                }
078:
079:                if (ostream == null) {
080:                    throw new Exception("Outputstream null!");
081:                }
082:
083:                String phpurl = "jdbc:mysql://" + phphost + "/" + phpdb;
084:                String mvnurl = "jdbc:mysql://" + mvnhost + "/" + mvndb;
085:
086:                try {
087:                    Class.forName("com.mysql.jdbc.Driver").newInstance();
088:                } catch (Exception E) {
089:                    System.err.println("Unable to load driver.");
090:                    E.printStackTrace();
091:                }
092:
093:                phpbb_c = DriverManager.getConnection(phpurl, phpuser, phppass);
094:
095:                if ((mvnhost == null) || (mvndb == null) || (mvnuser == null)
096:                        || (mvnpass == null)) {
097:                    mvnforum_c = null;
098:                } else {
099:                    mvnforum_c = DriverManager.getConnection(mvnurl, mvnuser,
100:                            mvnpass);
101:                }
102:
103:                sqlout = ostream;
104:            }
105:
106:            /**
107:             * Performs Conversion of phpbb database to mvnforum database
108:             */
109:            public void convert() {
110:                try {
111:
112:                    System.out.println("Conversion started...");
113:
114:                    Migrator.migrateUsers(sqlout, 0);
115:                    System.out.println("Users converted!");
116:
117:                    Migrator.migrateCategories(sqlout);
118:                    System.out.println("Categories converted!");
119:
120:                    Migrator.migrateForums(sqlout);
121:                    System.out.println("Forums converted!");
122:
123:                    Migrator.migratePosts(sqlout);
124:                    System.out.println("Posts converted!");
125:
126:                    Migrator.migrateThreads(sqlout);
127:                    System.out.println("Threads converted!");
128:
129:                    System.out.println("Conversion complete...");
130:
131:                } catch (SQLException E) {
132:                    System.out.println("Exception during conversion...");
133:                    System.out.println("SQLException: " + E.getMessage());
134:                    System.out.println("SQLState:     " + E.getSQLState());
135:                    System.out.println("VendorError:  " + E.getErrorCode());
136:                } catch (Exception e) {
137:                    e.printStackTrace();
138:                }
139:
140:                try {
141:                    phpbb_c.close();
142:                    if (mvnforum_c != null) {
143:                        mvnforum_c.close();
144:                    }
145:                } catch (SQLException e) {
146:                    e.printStackTrace();
147:                }
148:
149:                sqlout.close();
150:            }
151:
152:            public static void main(String[] args) throws Exception {
153:
154:                String phphost = "localhost";
155:                String phpdb = "peerflix_phpbb";
156:                String phpuser = "root";
157:                String phppass = "";
158:
159:                boolean dboutput = false;
160:                String mvnhost = "localhost";
161:                String mvndb = "mvnforum";
162:                String mvnuser = "root";
163:                String mvnpass = "";
164:
165:                String filename = "/home/haunt/Desktop/ele_out/out.sql";
166:
167:                //    for (int i=0; i<args.length; i++)
168:                //    {
169:                //      if (args[i].equals("-phpdb"))
170:                //      {
171:                //        phpdb = args[i+1];
172:                //        i++;
173:                //        continue;
174:                //      }
175:                //      else if (args[i].equals("-phphost"))
176:                //      {
177:                //        phphost = args[i+1];
178:                //        i++;
179:                //        continue;
180:                //      }
181:                //      else if (args[i].equals("-phpuser"))
182:                //      {
183:                //        phpuser = args[i+1];
184:                //        i++;
185:                //        continue;
186:                //      }
187:                //      else if (args[i].equals("-phppass"))
188:                //      {
189:                //        phppass = args[i+1];
190:                //        i++;
191:                //        continue;
192:                //      }
193:                //      else if (args[i].equals("-mvnhost"))
194:                //      {
195:                //        dboutput = true;
196:                //        mvnhost = args[i+1];
197:                //        i++;
198:                //        continue;
199:                //      }
200:                //      else if (args[i].equals("-mvndb"))
201:                //      {
202:                //        dboutput = true;
203:                //        mvndb = args[i+1];
204:                //        i++;
205:                //        continue;
206:                //      }
207:                //      else if (args[i].equals("-mvnuser"))
208:                //      {
209:                //        dboutput = true;
210:                //        mvnuser = args[i+1];
211:                //        i++;
212:                //        continue;
213:                //      }
214:                //      else if (args[i].equals("-mvnpass"))
215:                //      {
216:                //        dboutput = true;
217:                //        mvnpass = args[i+1];
218:                //        i++;
219:                //        continue;
220:                //      }
221:                //      else if (args[i].equals("-f"))
222:                //      {
223:                //        filename = args[i+1];
224:                //        i++;
225:                //        continue; 
226:                //      }
227:                //    }
228:                //    
229:                //    if ((phpdb == null) || (phpuser == null) || (phppass == null))
230:                //    {
231:                //      usage();
232:                //      System.exit(-1);
233:                //    }
234:                //    else if (dboutput == true)
235:                //    {
236:                //      if ((mvndb == null) || (mvnuser == null) || (mvnpass == null))
237:                //      {
238:                //        usage();
239:                //        System.exit(-1);
240:                //      }
241:                //    }
242:
243:                PrintStream ostream = System.out;
244:
245:                if (filename != null) {
246:                    File f = new File(filename);
247:                    FileOutputStream fout = new FileOutputStream(f);
248:                    ostream = new PrintStream(fout, true);
249:                }
250:
251:                (new RunningVersion(phphost, phpdb, phpuser, phppass, mvnhost,
252:                        mvndb, mvnuser, mvnpass, ostream)).convert();
253:            }
254:
255:            /**
256:             * 
257:             */
258:            private static void usage() {
259:
260:                System.out
261:                        .println("JavaReference.com PHPBB to MVNforum converter:\nUsage :");
262:                System.out
263:                        .println("java -jar phpbb2mvn.jar [-phphost [php_db_hostname]]  <-phpdb [php_db_name]> <-phpuser [php_db_user]> <-phppass [php_db_password]>");
264:                System.out
265:                        .println("                        [-mvnhost [mvn_db_hostname]  [-mvndb [mvn_db_name]] [-mvnuser [mvn_db_user]] [-mvnpass [mvn_db_password]]");
266:                System.out.println("                        [-f [filename]]");
267:                System.out
268:                        .println("All php* parameters (except -phphost) are mandatory. Default phphost is \"localhost\" ");
269:                System.out
270:                        .println("Specifying mvn* parameters are optional. If mvn* parameters are specified, the php database will be exported to the mvn database specified. "
271:                                + "-mvnhost parameter will default to \"localhost\" if not specified. ");
272:                System.out
273:                        .println("-f filename is optional, if not specified, output will go to stdout. If specified, a file will be created and the output will go to the file.");
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.