package com.mindprod.example;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import static java.lang.System.*;
/**
* demonstrate the how to connect in the Caucho Resin servlet womb.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2011-02-22 initial version
* @since 2011-02-22
*/
public class ConnectJDBCCauchoResin
{
/**
* which database
*/
private static final String DATA_BASE_NAME = "squirrels";
/**
* class name of the JDBC driver
*/
private static final String DRIVER_CLASS_NAME = "com.caucho.jdbc.mysql.Driver";
/**
* access PASSWORD
*/
private static final String PASSWORD = "sesame";
/**
* login name of user
*/
private static final String USERNAME = "charlie";
/**
* The connection. Handle to the database
*/
private static Connection conn;
/**
* connect to the database
*
* @return Connection to the database
* @throws java.sql.SQLException
*/
private static Connection connect() throws SQLException
{
try
{
Class.forName( DRIVER_CLASS_NAME );
}
catch ( Exception e )
{
err.println( "can't load SQL Server driver: " + e.getMessage() );
}
return DriverManager.getConnection( "jdbc:mysql-caucho://localhost:3306/" + DATA_BASE_NAME,
USERNAME,
PASSWORD );
}
/**
* initialise the database
*
* @param args not used
*
* @throws java.sql.SQLException
*/
public static void main( String[] args ) throws SQLException
{
conn = connect();
conn.close();
}
}