home *** CD-ROM | disk | FTP | other *** search
- package dsntool;
-
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Font;
- import java.awt.Frame;
- import java.awt.LayoutManager;
- import java.awt.Rectangle;
- import java.awt.TextArea;
- import java.awt.Window;
- import java.awt.event.ActionEvent;
- import java.awt.event.WindowEvent;
- import java.sql.Connection;
- import java.sql.Driver;
- import java.sql.SQLException;
- import java.util.Properties;
- import symantec.itools.awt.KeyPressManagerPanel;
- import symantec.itools.db.awt.LogonFrame;
- import symantec.itools.db.pro.ConnectionInfo;
- import symantec.itools.db.pro.RelationView;
- import symantec.itools.db.pro.Request;
- import symantec.itools.db.pro.Session;
- import symantec.itools.db.pro.SessionMetaData;
-
- public class TestBox extends Dialog {
- KeyPressManagerPanel kpm;
- Button OKButton;
- Button CancelButton;
- Button proButton;
- Button jdbcButton;
- TextArea display;
- Properties props;
- Connection jdbcServer;
- ConnectionInfo cinfo;
- DSN_ENGINE dsnEngine;
- Driver dbawDriver;
- RelationView rview;
- Request request;
- Session proServer;
- SessionMetaData proServerMetaData;
- LogonFrame proLogonFrame;
- private String serverUrl;
- private String engine;
- private String serverName;
- private String database;
- private String user;
- private String password;
- private String datasourcename;
- private String jdbcDriver = "symantec.itools.db.jdbc.Driver";
- private int protocol;
-
- public TestBox(Frame var1, String var2, String var3, DSN_ENGINE var4, String var5, String var6, String var7, String var8) {
- super(var1, "Test " + var2, true);
- ((Dialog)this).setResizable(false);
- ((Container)this).setLayout((LayoutManager)null);
- ((Component)this).resize(((Container)this).insets().left + ((Container)this).insets().right + 505, ((Container)this).insets().top + ((Container)this).insets().bottom + 390);
- this.kpm = new KeyPressManagerPanel();
- this.kpm.setLayout((LayoutManager)null);
- this.kpm.reshape(0, 0, 505, 400);
- ((Container)this).add(this.kpm);
- this.props = new Properties();
- this.props.put("user", var7);
- this.props.put("password", var8);
- this.display = new TextArea();
- this.display.setEditable(false);
- this.display.setFont(new Font("Helvetica", 0, 11));
- this.display.setBackground(Color.white);
- this.display.reshape(((Container)this).insets().left, ((Container)this).insets().top, 500, 320);
- this.jdbcButton = new Button("JDBC API Test");
- this.jdbcButton.setActionCommand("button");
- this.jdbcButton.setFont(new Font("Helvetica", 0, 11));
- this.jdbcButton.reshape(((Container)this).insets().left + 331, ((Container)this).insets().top + 330, 90, 20);
- this.OKButton = new Button("OK");
- this.OKButton.setActionCommand("button");
- this.OKButton.setFont(new Font("Helvetica", 0, 11));
- this.OKButton.reshape(((Container)this).insets().left + 67, ((Container)this).insets().top + 330, 90, 20);
- this.proButton = new Button("PRO API Test");
- this.proButton.setActionCommand("button");
- this.proButton.setFont(new Font("Helvetica", 0, 11));
- this.proButton.reshape(((Container)this).insets().left + 199, ((Container)this).insets().top + 330, 90, 20);
- this.kpm.add(this.display);
- this.kpm.add(this.OKButton);
- this.kpm.add(this.proButton);
- this.kpm.add(this.jdbcButton);
- this.serverUrl = new String(var3);
- this.engine = new String(var4.engineChoiceConnect.getSelectedItem());
- this.protocol = var4.protocolChoice.getSelectedIndex();
- this.serverName = new String(var5);
- this.database = new String(var6);
- this.user = new String(var7);
- this.password = new String(var8);
- this.datasourcename = new String(var2);
- this.proButton.requestFocus();
- this.dsnEngine = var4;
- SymWindow var9 = new SymWindow(this);
- ((Window)this).addWindowListener(var9);
- SymAction var10 = new SymAction(this);
- this.jdbcButton.addActionListener(var10);
- this.proButton.addActionListener(var10);
- this.OKButton.addActionListener(var10);
- }
-
- private final void closeJdbc() {
- this.display.appendText("\nClosing server...");
-
- try {
- this.jdbcServer.close();
- this.display.appendText("\t\t\t\t\t\t\tdone.");
- } catch (Exception var2) {
- this.display.appendText("\n\n***Exception caught: Could not close server.");
- this.display.appendText("\n ->" + ((Throwable)var2).toString());
- }
-
- this.display.appendText("\n<------------------------------------------------------------------------------------------------------------------>");
- }
-
- private final void closePro() {
- this.display.appendText("\n\nClosing server...");
-
- try {
- this.proServer.close();
- this.display.appendText("\t\t\t\t\t\t\tdone.");
- } catch (SQLException var2) {
- this.display.appendText("\n\n***SQLException caught: Could not close server.");
- this.display.appendText("\n ->" + ((Throwable)var2).toString());
- }
-
- this.display.appendText("\n<------------------------------------------------------------------------------------------------------------------>");
- }
-
- private final boolean connectJdbc() {
- String var1 = new String();
- boolean var2 = false;
- this.display.appendText("\n\nConnecting via the JDBC API with:");
- this.display.appendText("\n dbANYWHERE Server url:\t" + this.serverUrl);
- this.display.appendText("\n Engine:\t\t\t" + this.engine);
- if (this.serverUrl.charAt(this.serverUrl.length() - 1) == '/') {
- this.serverUrl = this.serverUrl.substring(0, this.serverUrl.length() - 1);
- }
-
- if (!this.engine.equalsIgnoreCase("SYBASE_SQLANY") && !this.engine.equalsIgnoreCase("WATCOM") && !this.engine.equalsIgnoreCase("MS_ACCESS") && !this.engine.equalsIgnoreCase("ODBC_XBASE_DSN") && !this.engine.equalsIgnoreCase("ODBC_DSN")) {
- if (!this.engine.equalsIgnoreCase("SQL_SERVER") && !this.engine.equalsIgnoreCase("INFORMIX") && !this.engine.equalsIgnoreCase("SYBASE_NT") && !this.engine.equalsIgnoreCase("SYBASE_WIN95")) {
- if (this.engine.equalsIgnoreCase("ORACLE_7")) {
- if (!this.dsnEngine.serverPrefix().equalsIgnoreCase("2:") && !this.dsnEngine.serverPrefix().equalsIgnoreCase("TNS:")) {
- var1 = "jdbc:" + this.serverUrl + "/" + this.engine + "/" + this.dsnEngine.serverPrefix() + this.serverName + "/" + this.database;
- } else {
- var1 = "jdbc:" + this.serverUrl + "/" + this.engine + "/" + this.dsnEngine.serverPrefix() + this.serverName + "/" + this.serverName;
- }
-
- TextArea var10000 = this.display;
- StringBuffer var10001 = new StringBuffer("\n Protocol:\t\t");
- DSN_ENGINE var3 = this.dsnEngine;
- int var4 = this.protocol;
- var10000.appendText(var10001.append(var3.protocolChoice.getItem(var4)).toString());
- this.display.appendText("\n Server/Service:\t\t" + this.serverName);
- this.display.appendText("\n Instance/SID:\t\t" + this.database);
- this.display.appendText("\n User:\t\t\t" + this.user);
- }
- } else {
- var1 = "jdbc:" + this.serverUrl + "/" + this.engine + "/" + this.serverName + "/" + this.database;
- this.display.appendText("\n Server:\t\t\t" + this.serverName);
- this.display.appendText("\n Database:\t\t" + this.database);
- this.display.appendText("\n User:\t\t\t" + this.user);
- }
- } else {
- var1 = "jdbc:" + this.serverUrl + "/" + this.engine + "/" + this.serverName + "/" + this.serverName;
- this.display.appendText("\n Datasource:\t\t" + this.serverName);
- this.display.appendText("\n User:\t\t\t" + this.user);
- }
-
- this.display.appendText("\n Connection String:\t\t" + var1);
- this.display.appendText("\n\nCreating new driver from " + this.jdbcDriver + "...");
-
- try {
- this.dbawDriver = (Driver)Class.forName(this.jdbcDriver).newInstance();
- this.display.appendText("\t\t\tdone.");
- var2 = true;
- } catch (InstantiationException var5) {
- this.display.appendText("\n\n***Exception caught: Could not make instantiation.");
- this.display.appendText("\n ->" + ((Throwable)var5).toString());
- this.display.appendText("\n<------------------------------------------------------------------------------------------------------------------>");
- } catch (ClassNotFoundException var6) {
- this.display.appendText("\n\n***Exception caught: Could not find class.");
- this.display.appendText("\n ->" + ((Throwable)var6).toString());
- this.display.appendText("\n<------------------------------------------------------------------------------------------------------------------>");
- } catch (IllegalAccessException var7) {
- this.display.appendText("\n\n***Exception caught: Could not access server.");
- this.display.appendText("\n ->" + ((Throwable)var7).toString());
- this.display.appendText("\n<------------------------------------------------------------------------------------------------------------------>");
- }
-
- if (var2) {
- this.display.appendText("\nOpening server...");
-
- try {
- this.jdbcServer = this.dbawDriver.connect(var1, this.props);
- this.display.appendText("\t\t\t\t\t\t\tdone.");
- return true;
- } catch (SQLException var8) {
- this.display.appendText("\n\n***Exception caught: Could not open server.");
- this.display.appendText("\n ->" + ((Throwable)var8).toString());
- this.display.appendText("\n<------------------------------------------------------------------------------------------------------------------>");
- }
- }
-
- return false;
- }
-
- private final boolean connectPro() {
- String var1 = new String();
- String var2 = new String();
- boolean var3 = false;
- this.display.appendText("\n\nConnecting via the dbANYWHERE/PRO API with:");
- this.display.appendText("\n dbANYWHERE Server url:\t" + this.serverUrl);
- this.display.appendText("\n Engine:\t\t\t" + this.engine);
- if (this.serverUrl.charAt(this.serverUrl.length() - 1) == '/') {
- this.serverUrl = this.serverUrl.substring(0, this.serverUrl.length() - 1);
- }
-
- if (!this.engine.equalsIgnoreCase("SYBASE_SQLANY") && !this.engine.equalsIgnoreCase("WATCOM") && !this.engine.equalsIgnoreCase("MS_ACCESS") && !this.engine.equalsIgnoreCase("ODBC_XBASE_DSN") && !this.engine.equalsIgnoreCase("ODBC_DSN")) {
- if (!this.engine.equalsIgnoreCase("SQL_SERVER") && !this.engine.equalsIgnoreCase("INFORMIX") && !this.engine.equalsIgnoreCase("SYBASE_NT") && !this.engine.equalsIgnoreCase("SYBASE_WIN95")) {
- if (this.engine.equalsIgnoreCase("ORACLE_7")) {
- if (!this.dsnEngine.serverPrefix().equalsIgnoreCase("2:") && !this.dsnEngine.serverPrefix().equalsIgnoreCase("TNS:")) {
- var1 = this.serverUrl + "/" + this.engine + "/" + this.dsnEngine.serverPrefix() + this.serverName + "/" + this.database;
- var2 = this.engine + "/" + this.dsnEngine.serverPrefix() + this.serverName + "/" + this.database;
- } else {
- var1 = this.serverUrl + "/" + this.engine + "/" + this.dsnEngine.serverPrefix() + this.serverName + "/" + this.serverName;
- var2 = this.engine + "/" + this.dsnEngine.serverPrefix() + this.serverName + "/" + this.serverName;
- }
-
- TextArea var10000 = this.display;
- StringBuffer var10001 = new StringBuffer("\n Protocol:\t\t");
- DSN_ENGINE var4 = this.dsnEngine;
- int var5 = this.protocol;
- var10000.appendText(var10001.append(var4.protocolChoice.getItem(var5)).toString());
- this.display.appendText("\n Server/Service:\t\t" + this.serverName);
- this.display.appendText("\n Instance/SID:\t\t" + this.database);
- this.display.appendText("\n User:\t\t\t" + this.user);
- }
- } else {
- var1 = this.serverUrl + "/" + this.engine + "/" + this.serverName + "/" + this.database;
- var2 = this.engine + "/" + this.serverName + "/" + this.database;
- this.display.appendText("\n Server:\t\t\t" + this.serverName);
- this.display.appendText("\n Database:\t\t" + this.database);
- this.display.appendText("\n User:\t\t\t" + this.user);
- }
- } else {
- var1 = this.serverUrl + "/" + this.engine + "/" + this.serverName + "/" + this.serverName;
- var2 = this.engine + "/" + this.serverName + "/" + this.serverName;
- this.display.appendText("\n Datasource:\t\t" + this.serverName);
- this.display.appendText("\n User:\t\t\t" + this.user);
- }
-
- this.display.appendText("\n Connection String:\t\t" + var1);
- this.display.appendText("\n ConnectionInfoObject:\t" + var2);
- this.display.appendText("\n\nCreating Session, LogonFrame, and Logon Failure Handler...");
-
- try {
- this.proServer = new Session(this.serverUrl, false);
- var3 = true;
- this.display.appendText("\t\tdone.");
- } catch (SQLException var7) {
- this.display.appendText("\n\n***SQLException caught: Unable to establish connection to specified dbANYWHERE Server.");
- this.display.appendText("\n ->" + ((Throwable)var7).toString());
- this.display.appendText("\n<------------------------------------------------------------------------------------------------------------------>");
- }
-
- this.cinfo = new ConnectionInfo(var2);
- this.cinfo.setAutoDisconnect(true);
- this.cinfo.setUser(this.user);
- this.cinfo.setPassword(this.password);
- if (var3) {
- var3 = false;
- this.display.appendText("\nOpening server...");
-
- try {
- this.proServerMetaData = this.proServer.getMetaData(this.cinfo);
- this.display.appendText("\t\t\t\t\t\t\tdone.");
- var3 = true;
- } catch (SQLException var6) {
- this.display.appendText("\n\n***metaDataError (SQLException caught): Unable to establish connection to specified database server.");
- this.display.appendText("\n ->" + ((Throwable)var6).toString());
- this.display.appendText("\n<------------------------------------------------------------------------------------------------------------------>");
- }
- }
-
- if (var3) {
- this.display.appendText("\n\nConnection information for " + this.proServerMetaData.getUserName() + ":");
- this.display.appendText("\n Driver Info:\t\t" + this.proServerMetaData.getDriverName() + " v." + this.proServerMetaData.getDriverVersion());
- this.display.appendText("\n Database:\t\t" + this.proServerMetaData.getDatabaseProductName());
- if (this.proServerMetaData.getDatabaseProductVersion().trim().length() != 0) {
- this.display.appendText(" v." + this.proServerMetaData.getDatabaseProductVersion());
- }
-
- if (this.proServerMetaData.allProceduresAreCallable()) {
- this.display.appendText("\n \t\t\tAll procedures are callable.");
- } else {
- this.display.appendText("\n \t\t\tSome procedures are not callable.");
- }
-
- if (this.proServerMetaData.allTablesAreSelectable()) {
- this.display.appendText("\n \t\t\tAll tables are selectable.");
- } else {
- this.display.appendText("\n \t\t\tSome tables are not selectable.");
- }
-
- return true;
- } else {
- return false;
- }
- }
-
- private final void disableButtons() {
- this.OKButton.disable();
- this.proButton.disable();
- this.jdbcButton.disable();
- }
-
- private final void enableButtons() {
- this.OKButton.enable();
- this.proButton.enable();
- this.jdbcButton.enable();
- }
-
- public synchronized void show() {
- Rectangle var1 = ((Component)this).getParent().bounds();
- Rectangle var2 = ((Component)this).bounds();
- ((Component)this).move(var1.x + (var1.width - var2.width) / 2, var1.y + (var1.height - var2.height) / 2);
- super.show();
- }
-
- private final void showError(String var1) {
- MsgBox var2 = new MsgBox((Frame)((Component)this).getParent(), "Exception caught", var1);
- var2.show();
- }
-
- private final void testJdbc() {
- this.OKButton.disable();
- this.proButton.disable();
- this.jdbcButton.disable();
- if (this.connectJdbc()) {
- this.closeJdbc();
- }
-
- this.OKButton.enable();
- this.proButton.enable();
- this.jdbcButton.enable();
- }
-
- private final void testPro() {
- this.OKButton.disable();
- this.proButton.disable();
- this.jdbcButton.disable();
- if (this.connectPro()) {
- this.closePro();
- }
-
- this.OKButton.enable();
- this.proButton.enable();
- this.jdbcButton.enable();
- }
-
- public synchronized void wakeUp() {
- this.notify();
- }
-
- void TestBox_WindowClosing(WindowEvent var1) {
- ((Window)this).dispose();
- }
-
- void jdbcButton_Clicked(ActionEvent var1) {
- this.OKButton.disable();
- this.proButton.disable();
- this.jdbcButton.disable();
- if (this.connectJdbc()) {
- this.closeJdbc();
- }
-
- this.OKButton.enable();
- this.proButton.enable();
- this.jdbcButton.enable();
- }
-
- void proButton_Clicked(ActionEvent var1) {
- this.OKButton.disable();
- this.proButton.disable();
- this.jdbcButton.disable();
- if (this.connectPro()) {
- this.closePro();
- }
-
- this.OKButton.enable();
- this.proButton.enable();
- this.jdbcButton.enable();
- }
-
- void OKButton_Clicked(ActionEvent var1) {
- ((Window)this).dispose();
- }
- }
-