diff --git a/.classpath b/.classpath index 91ee9a5..f074f2a 100644 --- a/.classpath +++ b/.classpath @@ -2,5 +2,7 @@ + + diff --git a/src/de/katho/kBorrow/Main.java b/src/de/katho/kBorrow/Main.java new file mode 100644 index 0000000..4506f31 --- /dev/null +++ b/src/de/katho/kBorrow/Main.java @@ -0,0 +1,21 @@ +package de.katho.kBorrow; + +import java.io.FileNotFoundException; +import java.sql.SQLException; +import java.sql.Statement; + +import de.katho.kBorrow.db.*; + +public class Main { + + public static void main(String[] args) { + try { + SqliteConnector sqlite = new SqliteConnector("test.db"); + } catch (FileNotFoundException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + +} diff --git a/src/de/katho/kBorrow/db/SqlConnector.java b/src/de/katho/kBorrow/db/SqlConnector.java new file mode 100644 index 0000000..0c7d99e --- /dev/null +++ b/src/de/katho/kBorrow/db/SqlConnector.java @@ -0,0 +1,5 @@ +package de.katho.kBorrow.db; + +public class SqlConnector { + +} diff --git a/src/de/katho/kBorrow/db/SqliteConnector.java b/src/de/katho/kBorrow/db/SqliteConnector.java new file mode 100644 index 0000000..42f1af6 --- /dev/null +++ b/src/de/katho/kBorrow/db/SqliteConnector.java @@ -0,0 +1,42 @@ +package de.katho.kBorrow.db; + +import java.io.File; +import java.io.FileNotFoundException; +import java.sql.*; + +/** + * @class sqliteConnector + * @author Servicepoint + * + * This class handles connections to a sqlite database. + */ +public class SqliteConnector { + private Connection connection; + private String dbHandle; + + /** + * @param dbHandle This string contains the path to database file the connector has to use + * @throws FileNotFoundException, SQLException + */ + public SqliteConnector(String dbHandle) throws SQLException, FileNotFoundException { + this.dbHandle = dbHandle; + File f = new File(this.dbHandle); + + if(!f.exists() || f.isDirectory()){ + throw new FileNotFoundException("Provided database file \""+this.dbHandle+"\" not found."); + } + + try { + Class.forName("org.sqlite.JDBC"); + + this.connection = DriverManager.getConnection("jdbc:sqlite:"+this.dbHandle); + Statement st = this.connection.createStatement(); + + st.executeUpdate("create table object (id integer, name string, comment string)"); + } + catch (ClassNotFoundException e){ + e.printStackTrace(); + } + } + +} diff --git a/src/de/katho/kBorrow/gui/MainWindow.java b/src/de/katho/kBorrow/gui/MainWindow.java new file mode 100644 index 0000000..6813cbd --- /dev/null +++ b/src/de/katho/kBorrow/gui/MainWindow.java @@ -0,0 +1,43 @@ +package de.katho.kBorrow.gui; + +import java.awt.EventQueue; + +import javax.swing.JFrame; + +public class MainWindow { + + private JFrame frame; + + /** + * Launch the application. + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + MainWindow window = new MainWindow(); + window.frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + /** + * Create the application. + */ + public MainWindow() { + initialize(); + } + + /** + * Initialize the contents of the frame. + */ + private void initialize() { + frame = new JFrame(); + frame.setBounds(100, 100, 450, 300); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + +}