initial commit

This commit is contained in:
2020-11-02 17:16:13 +01:00
parent 6fec9da43e
commit 31d74c1ac3
23 changed files with 260 additions and 89 deletions
@@ -0,0 +1,69 @@
package at.windesign.application.serie;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public enum serieDataSource
{
INSTANCE;
private static final String url = "jdbc:mysql://localhost:3306/multimedia";
private static final String user = "multimedia";
private static final String pwd = "WeissIchNicht8";
private Connection conn = null;
static
{
try
{
Class.forName("com.mysql.cj.jdbc.Driver");
} catch(ClassNotFoundException e)
{
e.printStackTrace();
}
}
private serieDataSource()
{
// drop the table if it exists
try
{
Statement stmt = this.getStatement();
stmt.close();
} catch(SQLException e)
{
e.printStackTrace();
} finally
{
this.close();
}
}
public Statement getStatement() throws SQLException
{
Statement stmt = null;
// get connection
conn = DriverManager.getConnection(url, user, pwd);
stmt = conn.createStatement();
return stmt;
}
public void close()
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
} catch(SQLException e)
{
e.printStackTrace();
}
}
}