HP Driver for JDBC User's Manual
82 AppendixD
Simple Client Source Code
{
/* User input fields */
String hostName = getString("Host Name: ");
String userName = getString("User Name: ");
String userPassword = getString("User Password: ");
String dbName = getString("Database Name: ");
/* Create the URL based on the user input */
String url = "jdbc:allbase://" +
hostName + "/" + dbName + "?";
/* Try to make the connection to the database */
try
{
/* Load the jdbc driver */
Class.forName("com.hp.jdbc.allbase.JdbcDriver");
/* Attempt to get a connection */
con = DriverManager.getConnection(url, userName, userPassword);
}
catch (SQLException ex)
{
System.out.println("SQLException caught during connection:");
printException(ex);
System.exit(0);
}
catch (Exception e)
{
System.out.println("Exception caught during connection:");