package com.x.run;
import com.gtsdesign.perseus.PerseusDriverDataSource;
import com.gtsdesign.perseus.PerseusConnectionFactory;
/**
This is the Perseus-generated SQL class.
**/
import com.x.test.UpdatePassword;
public class PasswordUpdater {
/**
The two lines of code in this method are all it
takes to create and use a SQL class.
The parameter order is determined by the order of
the parameters in the SQL statement.
*/
public void update (String newPassword, long customerId)
throw java.sql.SQLException {
UpdatePassword updater = new UpdatePassword (
newPassword, customerId
);
try {
updater.go ();
} catch (java.sql.SQLException e) {
e.printStackTrace ();
}
}
public static void main (String[] args) {
/*
Use the convenience method registerDriver() to
register the driver with the JDBC DriverManager.
*/
try {
PerseusDriverDataSource.registerDriver ("some.driver.class");
} catch (Exception e) {
e.printStackTrace ();
System.exit(1);
}
/*
We're using a JDBC I connection, so create a
PerseusDriverDataSource which presents a
DataSource interface for the JDBC I driver.
*/
PerseusDriverDataSource ds = new PerseusDriverDataSource ();
/*
Register the PerseusDriverDataSource with the
PerseusConnectionFactory. The
PerseusConnectionFactory is effectively a
singleton, and all Perseus connections are
acquired through it (yep, at the moment there
can only be one database connection at a
time). The argument may be any object which
implements the javax.sql.DataSource interface.
*/
PerseusConnectionFactory.setDataSource (ds);
String newPassword = args[0];
String customerId = args[1];
PasswordUpdater updater = new PasswordUpdater (newPassword, customerId);
updater.update (newPassword, customerId);
}
}