JPOS-EE installation: A small Java DB utility

Stuck with your JPOS-EE database installation? Beanshell dies at launch or fails to resolve class names? The small Java utility below (written in the Eclipse environment) may just be the answer to your woes.
Before you dive into Java code you may want to complete the following steps:
i. Download EasyPHP (WAMP server) and create a database called jposee.
ii. Start mysql and apache servers
  1. Start Eclipse.
  2. Create a new Java Project:
    1. File->New->Project.
    2. Select "Java" in the category list.
    3. Select "Java Project" in the project list. Click "Next".
    4. Enter a project name into the Project name field, for example, "JPOS-dbmaker".
    5. Click "Finish"--It will ask you if you want the Java perspective to open. (You do.)
  3. Create a new Java class:
    1. Click the "Create a Java Class" button in the toolbar. (This is the icon below "Project" with a tooltip that says "New Java Class.")
    2. Enter "dbmaker" into the Name field.
    3. Click the checkbox indicating that you would like Eclipse to create a "public static void main(String[] args)" method.
    4. Click "Finish".
  4. A Java editor for dbmaker.java will open. Remove all automatically generated code. Copy and paste the following code:
import java.util.*;
import org.jpos.ee.*;
import org.hibernate.*;
public class dbmaker {
/**
* @param args
*/
public static void main(String[] args) {
DB db = new DB();
db.createSchema (null, true);
db.open();
Transaction tx = db.beginTransaction();
User user = new User();
// user='admin', password='test'
user.setNick ("admin");
user.setPassword ("66d4aaa5ea177ac32c69946de3731ec0");
user.setName ("System Administrator");
user.grant ("login");
user.grant ("operator");
user.grant ("useradmin");
user.grant ("sysconfig");
user.grant ("admin");
db.session().save (user);
tx.commit();
db.close();
System.out.println("Processing complete");
}
}
  1. Save using ctrl-s. This automatically compiles dbmaker.java.
  2. Add jposee.jar to the build path: Right click JPOS-dbmaker in Package Explorer. Choose Build Path->Configure Build Path...->Add External JARS...
  3. Locate jpose-ee.jar in ..\trunk\build directory and add to Java Build Path
  4. Click the "Run" button in the toolbar.
  5. You will be prompted to create a Launch configuration. Select "Java Application" and click "New".
  6. Click "Run" to run the DB maker program. The console will open and display the following line at the bottom:
Processing complete

Comments

Popular posts from this blog

Whose Shilling?

Free mobile-to-mobile calls

Want to test midlets on real phones?