I still have a bit more stuff - mainly coding examples to put up but there should be a bit here for now. I have also added the last few publications, at least one more (hopefully two) to come!
Enjoy!
Hibernate aside, this is the class I have developed for simple, standard connection to a MySQL database using Java.
Requires JDBC.
+ –
import java.sql.*;
public class mysqldbcon
{
/*Database connection credentials*/
private String dbPath = "jdbc:mysql://localhost/";
private String dbUserName = "uname";
private String dbPassword = "pass";
private String dbName = "databasename";
private Connection sqlConn;
private Statement sqlStmt;
private ResultSet sqlRst;
private void connect( )
{
try {
Class.forName ("com.mysql.jdbc.Driver");
dbPath += dbName;
sqlConn = DriverManager.getConnection (dbPath, dbUserName, dbPassword);
sqlStmt = sqlConn.createStatement();
}
catch (Exception e) {
System.err.println("Unable to load mysql DB driver");
e.printStackTrace()
}
}
public ResultSet ExecuteSelectQuerySet(String sql)
{
ResultSet rs = null;
try{
connect();
rs = sqlStmt.executeQuery(sql);
close();
}
catch (SQLException e) {
e.printStackTrace();
}
return rs;
}
public void ExecuteNonQuery(String sql)
{
try{
connect();
sqlStmt.executeQuery(sql);
close();
}
catch (SQLException e) {
e.printStackTrace();
}
}
private void close()
{
try{
sqlRst.close();
sqlStmt.close();
sqlConn.close();
}
catch (Exception e) {
System.err.println("Unable to close mysql DB driver");
e.printStackTrace();
}
}
}