RRRRHHHH_Code
e2ae30e55bc2a997923463dd2a1274c67fdc73a6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
package dataAccess; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.border.EmptyBorder; import com.db4o.ObjectServer; import com.db4o.cs.Db4oClientServer; import com.db4o.cs.config.ServerConfiguration; import configuration.ConfigXML; import domain.Owner; public class DB4oManagerServer extends JDialog { private final JPanel contentPanel = new JPanel(); JTextArea textArea; ObjectServer server; private ServerConfiguration configurationCS; /** * Launch the application. */ public static void main(String[] args) { try { DB4oManagerServer dialog = new DB4oManagerServer(); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } /** * Create the dialog. */ public DB4oManagerServer() { setTitle("DB4oManagerServer: running the database server"); setBounds(100, 100, 486, 180); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); { textArea = new JTextArea(); contentPanel.add(textArea); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("OK"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.append("\n\n\nClosing the database... "); try { server.close(); } catch (Exception e1) { } System.exit(1); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } ConfigXML c=ConfigXML.getInstance(); try{ if (c.getDataBaseOpenMode().equals("initialize")) new File(c.getDb4oFilename()).delete(); configurationCS = Db4oClientServer.newServerConfiguration(); configurationCS.common().activationDepth(c.getActivationDepth()); configurationCS.common().updateDepth(c.getUpdateDepth()); configurationCS.common().objectClass(Owner.class).cascadeOnDelete(true); server = Db4oClientServer.openServer(configurationCS, c.getDb4oFilename(),c.getDatabasePort()); textArea.append("\nConnection to the database '"+c.getDb4oFilename()+"' opened in port "+c.getDatabasePort()); server.grantAccess(c.getUser(),c.getPassword()); textArea.append("\nAccess granted to: "+c.getUser()); textArea.append("\nPress button to exit this database server... "); } catch (Exception e) { textArea.append("Something has happened in DB4oManagerServer: "+e.toString()); } } } |
Commits for RRRRHHHH_CoderuralHouses/src/dataAccess/DB4oManagerServer.java
Revision | Author | Commited | Message |
---|---|---|---|
e2ae30 ... Diff | Eneko Pinzolas Murua | Tue 14 Apr, 2015 15:07:35 +0000 | imports leaned |
06a849 ... | pinene | Sat 07 Mar, 2015 13:48:38 +0000 | unification with the actual initial project. Some things are new now, but there has been a feature that has been deleted.\n The feature of opening and closing the database per each query/store has been deleted by now |