Hi, All.
I am working on a project with another student that will be used on Oracle, MySWL and DB2 databases. We have completed all the basic functions, but I would like to see if we can improve on one aspect of the code.
Scenario: There are 5 bank tables
private final String[]
tableList = {"account" , "branch", "customer", "depositor" , "loan", "borrower"} ;
There is a string array for the table schemas
private final String[]
tableSchema = {"CREATE TABLE ACCOUNT( BRANCH_NAME CHAR(10),ACCOUN T_NUMBER CHAR(5) ,BALANCE DECIMAL(3,0))",
"CREATE TABLE BRANCH (BRANCH_NAME CHAR(10),BRANCH _CITY CHAR(15), ASSETS DECIMAL(10,2))" ,
"CREATE TABLE CUSTOMER (CUSTOMER_NAME CHAR(10),CUSTOM ER_STREET CHAR(20),CUSTOM ER_CITY CHAR(15))",
"CREATE TABLE DEPOSITOR (CUSTOMER_NAME CHAR(10),ACCOUN T_NUMBER CHAR(5))",
"CREATE TABLE LOAN (BRANCH_NAME CHAR(10),LOAN_N UMBER CHAR(4) ,AMOUNT DECIMAL(10,2))" ,
"CREATE TABLE BORROWER ( CUSTOMER_NAME CHAR(10), LOAN_NUMBER CHAR(4))" };
And there are string arrays for the information to be inserted in the tables.
private final String[][]
tableRow = {
// Account table data
{"'Downtown' ,'A-101',500",
"'Mianus', 'A-215', 700",
"'Perryridg e', 'A-102', 400",
"'Round Hill', 'A-305', 350",
"'Perryridg e', 'A-201', 900",
"'Redwood', 'A-222', 700",
"'Brighton' , 'A-217', 750"},
// Branch table data
{"'Downtown','B rooklyn', 9000000",
"'Redwood','Pal o Alto', 2100000",
"'Perryridge',' Horseneck',1700 000",
"'Mianus','Hors eneck', 400000",
"'Round Hill','Horsenec k',8000000",
"'Pownal','Benn ington',300000" ,
"'North Town','Rye',370 0000",
"'Brighton','Br ooklyn', 7100000"},
// Customer table data
{"'Jones' ,'Main' ,'Harrison'",
"'Smith' ,'North' ,'Rye'",
"'Hayes' ,'Main' ,'Harrison'",
"'Curry' ,'North' ,'Rye'",
"'Lindsay' ,'Park' ,'Pittsfield'",
"'Turner' ,'Putnam' ,'Stamford'",
"'Williams' ,'Nassau' ,'Princeton'",
"'Adams' ,'Spring' ,'Pittsfield'",
"'Johnson' ,'Alma' ,'Palo Alto'",
"'Glenn' ,'Sand' ,'Hill Woodside'",
"'Brooks' ,'Senator' ,'Brooklyn'",
"'Green' ,'Walnut' ,'Stamford'"},
// Depositor table data
{"'Hayes' ,'A-102'",
"'Johnson' ,'A-101'",
"'Johnson' ,'A-201'",
"'Jones' ,'A-217'",
"'Lindsay' ,'A-222'",
"'Smith' ,'A-215'",
"'Turner' ,'A-305'"},
// Loan table data
{"'Downtown' ,'L-17' ,'1000'",
"'Redwood' ,'L-23' ,'2000'",
"'Perryridg e' ,'L-15' ,'1500'",
"'Downtown' ,'L-14' ,'1500'",
"'Mianus' ,'L-93' ,'500'",
"'Round Hill' ,'L-11' ,'900'",
"'Perryridg e' ,'L-16' ,'1300'"},
// Borrower table data
{"'Adams' ,'L-16'",
"'Curry' ,'L-93'",
"'Hayes' ,'L-15'",
"'Jones' ,'L-17'",
"'Smith' ,'L-11'",
"'Smith' ,'L-23'",
"'Williams' ,'L-17'"}
};
The current code supports the user selecting what they want to do by command line commands. Ex. Create [tablename];Load [tablename];Drop [tablename], etc.
I have the code to create “ALL’ of the tables, which works fine
case CREATE:
{
if (op.length < 2)
{
System.out.prin tln("Error! can not " + op[0] + "table due to missing table name");
displayValidTab le(tableList);
break;
}
tableName = op[1];
curTableCode = getTableCode(ta bleName.toLower Case(), tableList);
switch (curTableCode){
case ALL:
for (int i=0;i < tableList.lengt h;i++){
dbase.executeSQ LdllQuery(table Schema[i]);
}
dbase.closeConn ection();
break;
Now here is my dilemma:
I would like to be able to use the current code structure to add a CASE ALL: to the loading of the information into the tables (see below) and to the dropping of all of the tables, without having the user name them individually.
Any ideas?
Load Table Code:
case LOAD:
{
if (op.length < 2)
{
System.out.prin tln("Error! can not load table due to missing table name");
displayValidTab le(tableList);
break;
}
tableName = op[1];
curTableCode = getTableCode(ta bleName.toLower Case(), tableList);
LoadTable (dbase, tableName, tableRow[curTableCode]);
dbase.closeConn ection();
break;
}
private void LoadTable(Dbase Bean dbasel, String tableName, String tableRow[]){
dbasel.executeS QLdllQuery("DEL ETE FROM " + tableName);
for (int i=0; i < tableRow.length ; i++)
{
dbasel.executeS QLdllQuery("INS ERT INTO " + tableName + " VALUES (" + tableRow[i]+")");
}
DROP TABLE code:
case DROP:
{
if (op.length < 2)
{
System.out.prin tln("Error! can not create table due to missing table name");
displayValidTab le(tableList);
break;
}
tableName = op[1];
dropTable (dbase, tableName);
dbase.closeConn ection();
break;
}
private void dropTable(Dbase Bean dbasel, String tableName){
dbasel.executeS QLdllQuery("DRO P TABLE " + tableName);
}
Thank you for any help you can provide.
0 2755 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Philip D Heady |
last post by:
Ok, as some of you may know I'm an Oracle newbie w/ PHP. I'd rather use
MySQL but at the office here we use Oracle and boy do I have alot to learn.
I'm starting to hate it after using MySQL!!
--------------------------------------------------------------------------
1) Is there a similar statement using PHP/Oracle functions as below for
MySQL?
--------------------------------------------------------------------------
while (list...
|
by: MS |
last post by:
Hi,
In my Genetic Algorithm program, I have a class called Genome. Another
class called GA has a class variable called 'population' which is an array
of type Genome.
One of the methods in GA, called CreateNextGeneration(), creates a local
array of class Genome called 'nextGeneration', and at the end of that
method I want the class variable 'population' to hold the array
'nextGeneration'.
|
by: Matt Liverance |
last post by:
I REALLY dont want to switch to oracle :( but I cant get these tables
working any faster.
I've got 2 dedicated servers, each with a slave, all run 32gig 15k rpm
raid 5 on u320 perc raid cards, dell 2600/4600's with single channel
backplanes (new ones will have dual channel)
All have 2 gig of ram, but I've never seen mysql use more than 300mb
of ram.
|
by: Ali |
last post by:
Hello,
I have written a utility in C# using ODBC.NET. It can fetch information
from a ODBC supported database table and copy it to the other ODBC
supported DB table; provided the tables exist on both databases with
similar schema.
This is running fine when I transder data from Oracle to DB2, MySQL to
Oracle and vice versa. But it fails from DB2 to Oracle.
I am using Datasets to retrieve data (using Select command of
|
by: Galina |
last post by:
Hello
I need to get data from 4 Oracle tables and combine them into a
temporary table in my application. I get data using a pass-through
query dynamically created in code:
mySQL = "SELECT SID_SCREENING_TASKS_QUESTIONS.TASK_ID,
mySQL = mySQL & "SID_SCREENING_TASKS_QUESTIONS.ID,
mySQL = mySQL & "SID_SCREENING_QUESTIONS.TITLE, "
mySQL = mySQL & "SID_SCREENING_QUESTION_STUDENT.Points "
mySQL = mySQL & "from SID_SCREENING_TASKS_QUESTIONS,...
| |
by: John Smith |
last post by:
I know that uploading an image to a database has been covered, oh, about 3
trillion times. However, I haven't found anything covering uploading to a
MySQL database with .net. Please don't recommend storing the image to the
filesystem and only keeping a pointer to that in the table. I want to dump
the image to a table. My code dumps the data into the table, however, I get
the following error when trying to view the image "the image ......
|
by: spwpreston |
last post by:
Hello,
I am new to MySQL. I am trying to load from a text file to a table,
and am having problems
with the fields in the text file being translated to the correct fields
in the TABLE. Right now,
I have a tab between each field in the text file, something like:
Chicago USA 2,500,000
New York USA 5,000,000
|
by: Jim |
last post by:
Hi,
I capture data from an none db source using perl and then every night I
load the mysql table with the new data.
Can someone explain to me the best way to do that? It takes 30 minutes
or more to load the data, so I want to store it in a temporary table
and then load it into the permanent table without losing the
characteristics of the DB.
|
by: polocar |
last post by:
Hi,
I'm writing a program in Visual C# 2005 Professional Edition.
This program connects to a SQL Server 2005 database called
"Generations" (in which there is only one table, called
"Generations"), and it allows the user to add, edit and delete the
various records of the table.
"Generations" table has the following fields:
"IDPerson", NamePerson", "AgePerson" and "IDParent".
A record contains the information about a person (his name, his...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |