我点击applet中的按钮调用embeddedNeo4j程序。它在语句之前执行所有语句
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH);
启动数据库服务器。另外,在直接运行EmbeddedNo4j时,服务器启动
我的applet的actionPerformed如下
public void actionPerformed(ActionEvent ae)
{
Firstname=t1.getText();
Lastname=t2.getText();
Birthdate=t3.getText();
if(r1.isSelected())
{Gender=r1.getText();
}
else
Gender=r2.getText();
State=t4.getText();
City=t5.getText();
Hobby=jl1.getSelectedItem();
Education=jl2.getSelectedItem();
Occupation=jl3.getSelectedItem();
HobbyS=Hobby.toString();
EducationS=Education.toString();
OccupationS=Occupation.toString();
JOptionPane.showMessageDialog( frame,"BEFORE FUNCTION CALL");
callFunction();
}
public void callFunction()
{
JOptionPane.showMessageDialog( frame,"IN FUNCTION");
String test;
String test1; String test2; JOptionPane.showMessageDialog( frame," CREATE OBJECT NOW"); EmbeddedNeo4j hello = new EmbeddedNeo4j(); JOptionPane.showMessageDialog( frame,"OBJECT CREATED"); test1=hello.verify(Firstname); test2=hello.start() ; tExtra.setText(test2); test=hello.createDb(Firstname,Lastname,Gender,State,City,HobbyS,EducationS,OccupationS); JOptionPane.showMessageDialog( frame,test); }my EmbeddedNeo4j Program is as follows public class EmbeddedNeo4j { final String DB_PATH = "C://neo4j-community-1.9.6//data//graph.db"; String greeting; GraphDatabaseService graphDb; Node firstNode; String start() { String k=""; try { graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( DB_PATH);//This statement is creating problem return k; } catch(Exception e) { k=Arrays.toString(Thread.currentThread().getStackTrace()); System.out.println(k); return k; } } String verify(String fn) { String fn1=fn; return fn1; } String createDb(String Firstname,String Lastname,String Gender,String State,String City,String Hobby,String Education,String Occupation) { Transaction tx=null; try { tx= graphDb.beginTx(); firstNode.setProperty( "firstName", ""+Firstname+"" ); firstNode.setProperty( "LastName", Lastname ); firstNode.setProperty( "Gender", Gender ); firstNode.setProperty( "State", State ); firstNode.setProperty( "City", City ); firstNode.setProperty( "Hobby", Hobby ); firstNode.setProperty( "Education", Education ); firstNode.setProperty( "Occupation", Occupation );
System.out.print( firstNode.getProperty( "firstName"));
System.out.print( firstNode.getProperty( "LastName" ));
System.out.print( firstNode.getProperty( "Age" ) );
System.out.print( firstNode.getProperty( "Gender") );
System.out.print( firstNode.getProperty( "State" ) );
System.out.print( firstNode.getProperty( "City") );
System.out.print( firstNode.getProperty( "Hobby") );
System.out.print( firstNode.getProperty("Education") );
System.out.print( firstNode.getProperty( "Occupation") );
greeting = ( (String) firstNode.getProperty( "firstName" ) )
+ ( (String) firstNode.getProperty( "LastName" ))
+ ( (String) firstNode.getProperty( "Age" ))
+ ( (String) firstNode.getProperty( "Gender" ))
+ ( (String) firstNode.getProperty( "State" ))
+ ( (String) firstNode.getProperty( "City" ))
+ ( (String) firstNode.getProperty( "Hobby"))
+ ( (String) firstNode.getProperty( "Education" ))
+ ( (String) firstNode.getProperty( "Occupation" ));
tx.success();
}
catch(Exception e)
{
tx.failure();
}
finally
{
tx.finish();
return greeting;
}
// END SNIPPET: transaction
}
运行我的applet后的StackTrace如下
[java.lang.Thread.getStackTrace(Thread.java:1588),
EmbeddedNeo4j.start(EmbeddedNeo4j.java:48),
form.callFunction(form.java:170),
form.actionPerformed(form.java:151),
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018),
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341),
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402),
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259),
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252),
java.awt.Component.processMouseEvent(Component.java:6505),
javax.swing.JComponent.processMouseEvent(JComponent.java:3320),
java.awt.Container.processEvent(Container.java:2229),
java.awt.Component.dispatchEventImpl(Component.java:4861),
java.awt.Container.dispatchEventImpl(Container.java:2287),
java.awt.Component.dispatchEvent(Component.java:4687),
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832),
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492),
java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422),
java.awt.Container.dispatchEventImpl(Container.java:2273),
java.awt.Component.dispatchEvent(Component.java:4687),
java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735),
java.awt.EventQueue.access$200(EventQueue.java:103),
java.awt.EventQueue$3.run(EventQueue.java:694),
java.awt.EventQueue$3.run(EventQueue.java:692),
java.security.AccessController.doPrivileged(Native Method),
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76),
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87),
java.awt.EventQueue$4.run(EventQueue.java:708),
java.awt.EventQueue$4.run(EventQueue.java:706),
java.security.AccessController.doPrivileged(Native Method),
java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76),
java.awt.EventQueue.dispatchEvent(EventQueue.java:705),
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242),
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161),
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150),
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146),
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138),
java.awt.EventDispatchThread.run(EventDispatchThread.java:91)]
另外,我的DB_PATH /消息是空的。:( Plz指导我