Skip to content

Instantly share code, notes, and snippets.

@skuro
Created January 29, 2010 17:08
Show Gist options
  • Save skuro/289900 to your computer and use it in GitHub Desktop.
Save skuro/289900 to your computer and use it in GitHub Desktop.
package foo;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
/**
* Hello world application to test the use of emptyStringsConvertToZero param for MySQL JDBC Driver
*
*/
public class App
{
public static void main( String[] args )
{
Connection connection = null;
try {
Class.forName("com.mysql.jdbc.Driver");
// Setup the connection with the DB
connection = DriverManager
.getConnection("jdbc:mysql://localhost/removeme?"
+ "user=removeme&password=removeme&"
+ "emptyStringsConvertToZero=true&jdbcCompliantTruncation=false");
// Statements allow to issue SQL queries to the database
Statement statement = connection.createStatement();
// Result set get the result of the SQL query
Boolean result = statement
.execute("INSERT INTO removeme.removeme VALUES (\"\")");
// writeResultSet(resultSet);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
if (connection != null)
{
try {
connection.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment