/*
* Copyright (c) 1996-2001 Borland Software Corporation. All Rights Reserved.
*
* This SOURCE CODE FILE, which has been provided by Borland Software as part
* of an Borland Software product for use ONLY by licensed users of the product,
* includes CONFIDENTIAL and PROPRIETARY information of Borland Software.
*
* USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
* OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
* THE PRODUCT.
*
* IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND SOFTWARE, ITS
* RELATED COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY
* CLAIMS OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR
* DISTRIBUTION OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES
* ARISING OUT OF OR RESULTING FROM THE USE, MODIFICATION, OR
* DISTRIBUTION OF PROGRAMS OR FILES CREATED FROM, BASED ON, AND/OR
* DERIVED FROM THIS SOURCE CODE FILE.
*/
//------------------------------------------------------------------------------
// Copyright (c) 1996-2001 Borland Software Corporation. All Rights Reserved.
//------------------------------------------------------------------------------
package com.borland.samples.dx.storedprocedures;
import java.awt.*;
import java.awt.event.*;
import com.borland.dx.dataset.*;
import com.borland.dx.sql.dataset.*;
public class StoredProcedureDM implements DataModule{
private static StoredProcedureDM myDM;
Database currentDatabase = new Database();
QueryDataSet masterQDS = new QueryDataSet();
ProcedureDataSet detailPDS = new ProcedureDataSet();
ProcedureResolver detailPR = new ProcedureResolver();
Column column1 = new Column();
// InterBase via InterClient:
final String url = "jdbc:interbase://localhost/C:/Dokumente und Einstellungen/Juergen/Eigene Dateien/Programme/IB65_server_edit/IB65_win32/Server/examples/database/employee.gdb";
final String driver = "interbase.interclient.Driver";
final String ddlFile = "C:/JBuilder7/samples/DataExpress/ServerSpecificProcedures/sqlInterBase.sql";
final String ddlDropFile = "C:/JBuilder7/samples/DataExpress/ServerSpecificProcedures/sqlDrop.sql";
final boolean acceptCR = true;
final boolean semiColon = false;
final String username = "sysdba";
final String password = "masterkey";
final String masterQuery = "select * from employee";
final String callProvide = "select * from SAMPLEEMPINFO
DEPTID)";
final String callInsert = "execute procedure SAMPLEINSEMP :EMPID, :FNAME, :LNAME,
HIRE, :SALARY,
ARAMETER.DEPTID";
final String callUpdate = "execute procedure SAMPLEUPDEMP :ORIGINAL.EMPID, :EMPID, :FNAME, :LNAME,
HIRE, :SALARY,
EPTID";
final String callDelete = "execute procedure SAMPLEDELEMP :EMPID";
public StoredProcedureDM() {
try {
jbInit();
}
catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception{
currentDatabase.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor(url, username, password, false, driver));
masterQDS.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(currentDatabase, masterQuery, null, true, Load.ALL));
column1.setColumnName("EMPID");
column1.setDataType(Variant.INT);
column1.setRowId(true);
detailPDS.setProcedure(new com.borland.dx.sql.dataset.ProcedureDescriptor(currentDatabase, callProvide, masterQDS, true, Load.ALL));
detailPDS.setMetaDataUpdate(MetaDataUpdate.TABLENAME+MetaDataUpdate.PRECISION+MetaDataUpdate.SCALE+MetaDataUpdate.SEARCHABLE);
detailPDS.setResolver(detailPR);
detailPDS.setColumns(new Column[] {column1});
detailPR.setDatabase(currentDatabase);
detailPR.setInsertProcedure(new com.borland.dx.sql.dataset.ProcedureDescriptor(currentDatabase, callInsert, masterQDS, true, Load.ALL));
detailPR.setUpdateProcedure(new com.borland.dx.sql.dataset.ProcedureDescriptor(currentDatabase, callUpdate, masterQDS, true, Load.ALL));
detailPR.setDeleteProcedure(new com.borland.dx.sql.dataset.ProcedureDescriptor(currentDatabase, callDelete, null, true, Load.ALL));
detailPDS.setMasterLink(new com.borland.dx.dataset.MasterLinkDescriptor(masterQDS, new String[] {"DEPTID"}, new String[] {"DEPTID"}, true, false, false));
}
public static StoredProcedureDM getDataModule() {
// return new StoredProcedureDM();
if (myDM == null)
myDM = new StoredProcedureDM();
return myDM;
}
public boolean isAcceptCR() {
return acceptCR;
}
public boolean isKeepSemiColon() {
return semiColon;
}
public String getDDLquery() {
return ddlFile;
}
public String getDropDDLquery() {
return ddlDropFile;
}
public com.borland.dx.sql.dataset.Database getCurrentDatabase() {
return currentDatabase;
}
public com.borland.dx.sql.dataset.ProcedureDataSet getDetailPDS() {
return detailPDS;
}
public com.borland.dx.sql.dataset.QueryDataSet getMasterQDS() {
return masterQDS;
}
}
die verbindung zur datenbank funktioniert. mit select * from employee bekomme ich die daten aus der employee database. das sind die einzelnen tabellen:
DEPT_NO
EMP_NO
FIRST_NAME
FULL_NAME
HIRE_DATE
JOB_CODE
JOB_COUNTRY
JOB_GRADE
LAST_NAME
PHONE_EXT
SALARY
das problem ist nun das er mir beim starten des programmes sagt, dass ich keine spalte deptid in meiner datenbank habe, womit er auch recht hat. in dem nun aber diese spalte fehlt kann ich das programm nicht weiterverfolgen und ich weiss nicht, ob er mit obigen anweisungen bereits eine verbindung zu meinen prozeduren (die im beipsiel in einem ordner namens sql script abgelegt sind) hergestellt hat.
ich weiss nicht ob das nicht etwas zu mühsam ist für einen aussenstehenden sich da hineinzudenken. gewaltig geholfen wäre mir bereits wenn das obige beispiel ohne die deptid spalte auskommen würde. das ist baer nicht so leicht,da auch in den gespeicherten prozeduren nach deptid gefragt wird. scheint so als müsste ich mir ein anderes beispiel suchen. nur wo finden?
mfg
juergen