Using an SQL table in a Java program?
Hello, I am quite new to programming and would like to know if it is possible to have an SQL database as a backend, linked to my Java program?
If it is pobbible, could someone give me breif overview of the procedure.
Much appriciated.
Thankyou
Yes, use JDBC:
http://java.sun.com/docs/books/tutorial/jdbc/
MOD
Similar Messages
-
How to display a oracle table from a java program?
How to display a oracle table from a java program.
Hello friends, I have written a Java program, using oracle 10g as backend.
I want to display a oracle table as output. Im not getting how to display oracle table as a output table.. Pls help me
Thank youjayanthds, you're not going to get a satisfactory
answer to this here. it's too big a task to justbe
quickly outlined in a forum - the reply "all youneed
to do is to query you table and return it asJTable"
is worthless, for example, since the solution to
any problem can be distilled to such a
soundbite, if need be. doesn't make the solutionany
simpler
essentially you're asking "how do I write adatabase
application?". all you'll get is snippets of code
that, when fitted together, will eventually helpyou
do this, but you'll spend days and days comingback
saying "right, I've done that, now what?" until
either you or the forum gets frustrated with the
whole affair and the process stops
there are entire books written about this subject,
and countless tutorials and guides on theinternet.
you're better off going down that routehehehe.well, it's true! I used to have a manager that would outline the solution to a problem in a few lines of pseudocode, and then firmly believe that the actual solution would be just as brief and simple. shame his pseudocode included such lofty abstractions as "reformat all data" -
Hi all,
can you guys suggest me how can I use pl/sql tables for the below query to incresing the performance.
DECLARE
TYPE cur_typ IS REF CURSOR;
c cur_typ;
total_val varchar2(1000);
sql_stmt varchar2(1000);
freeform_name NUMBER;
freeform_id NUMBER;
imgname_rec EMC_FTW_PREVA.EMC_Image_C_Mungo%rowtype;
imgval_rec EMC_FTW_PREVA.EMC_Content_C_Mungo%rowtype;
CURSOR imgname_cur IS
select * from EMC_FTW_PREVA.EMC_Image_C_Mungo
where cs_ownerid in (
select id from EMC_FTW_PREVA.EMC_Image_C
where updateddate > '01-JUN-13'
and path is not null
and createddate != updateddate)
and cs_attrid = (select id from EMC_FTW_PREVA.EMC_ATTRIBUTE where name = 'Image_Upload');
BEGIN
OPEN imgname_cur;
LOOP
FETCH imgname_cur INTO imgname_rec;
EXIT WHEN imgname_cur%NOTFOUND;
total_val := 'EMC_Image_C_' || imgname_rec.cs_ownerid;
sql_stmt := 'SELECT instr(textvalue,''' || total_val || '''), cs_ownerid FROM EMC_FTW_PREVA.EMC_Content_C_Mungo a Where cs_attrid = (select id from EMC_FTW_PREVA.EMC_ATTRIBUTE where name = ' || '''' || 'Body_freeform' || '''' || ')';
OPEN c FOR sql_stmt;
LOOP
FETCH c INTO freeform_id,freeform_name;
EXIT WHEN c%NOTFOUND;
IF freeform_id > 0 THEN
dbms_output.put_line (imgname_rec.cs_ownerid || ',' || total_val || ',' || freeform_id || ',' || freeform_name);
END IF;
END LOOP;
CLOSE c;
END LOOP;
CLOSE imgname_cur;
END;
Thanks in Advance.can you guys suggest me how can I use pl/sql tables for the below query to incresing the performance.
There would be absolutely no point at all in improving the performance of code that has NO benefit.
The only result of executing that code is to possibly produce some lines of output AFTER the entire procedure if finished:
dbms_output.put_line (imgname_rec.cs_ownerid || ',' || total_val || ',' || freeform_id || ',' || freeform_name);
So first you need to explain:
1. what PROBLEM you are trying to solve?
2. why you are trying to use PL/SQL code to solve it.
3. why are you using 'slow by slow' (row by row) processing and then, for each row, opening a new cursor to query more data?
You should be using a single query rather than two nested cursors. But that begs the question of what the code is even supposed to be doing since the only output is going to a memory buffer. -
Huge memory leaks in using PL/SQL tables and collections
I have faced a very interesting problem recently.
I use PL/SQL tables ( Type TTab is table of ... index by binary_integer; ) and collections ( Type TTab is table of ...; ) in my packages very widely. And have noticed avery strange thing Oracle does. It seems to me that there are memory leaks in PGA when I use PL/SQL tables or collections. Let me a little example.
CREATE OR REPLACE PACKAGE rds_mdt_test IS
TYPE TNumberList IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
PROCEDURE test_plsql_table(cnt INTEGER);
END rds_mdt_test;
CREATE OR REPLACE PACKAGE BODY rds_mdt_test IS
PROCEDURE test_plsql_table(cnt INTEGER) IS
x TNumberList;
BEGIN
FOR indx IN 1 .. cnt LOOP
x(indx) := indx;
END LOOP;
END;
END rds_mdt_test;
I run the following test code:
BEGIN
rds_mdt_test.test_plsql_table (1000000);
END;
and see that my session uses about 40M in PGA.
If I repeat this example in the same session creating the PL/SQL table of smaller size, for instance:
BEGIN
rds_mdt_test.test_plsql_table (1);
END;
I see again that the size of used memory in PGA by my session was not decreased and still be the same.
The same result I get if I use not PL/SQL tables, but collections or varrays.
I have tried some techniques to make Oracle to free the memory, for instance to rewrite my procedure in the following ways:
PROCEDURE test_plsql_table(cnt INTEGER) IS
x TNumberList;
BEGIN
FOR indx IN 1 .. cnt LOOP
x(indx) := indx;
END LOOP;
x.DELETE;
END;
or
PROCEDURE test_plsql_table(cnt INTEGER) IS
x TNumberList;
BEGIN
FOR indx IN 1 .. cnt LOOP
x(indx) := indx;
END LOOP;
FOR indx in 1 .. cnt LOOP
x.DELETE(indx);
END LOOP;
END;
or
PROCEDURE test_plsql_table(cnt INTEGER) IS
x TNumberList;
empty TNumberList;
BEGIN
FOR indx IN 1 .. cnt LOOP
x(indx) := indx;
END LOOP;
x := empty;
END;
and so on, but result was the same.
This is a huge problem for me as I have to manipulate collections and PL/SQL tables of very big size (from dozens of thousand of rows to millions or rows) and just a few sessions running my procedure may cause server's fall due to memory lack.
I can not understand what Oracle reseveres such much memory for (I use local variables) -- is it a bug or a feature?
I will be appreciated for any help.
I use Oracle9.2.0.1.0 server under Windows2000.
Thank you in advance.
Dmitriy.Thank you, William!
Your advice about using DBMS_SESSION.FREE_UNUSED_USER_MEMORY was very useful. Indeed it is the tool I was looking for.
Now I write my code like this
declare
type TTab is table of ... index binary_integer;
res TTab;
empty_tab TTab;
begin
res(1) := ...;
res := empty_tab;
DBMS_SESSION.FREE_UNUSED_USER_MEMORY;
end;
I use construction "res := empty_tab;" to mark all memory allocated to PL/SQL table as unused according to Tom Kyte's advices. And I could live a hapy life if everything were so easy. Unfortunately, some tests I have done showed that there are some troubles in cleaning complex nested PL/SQL tables indexed by VARCHAR2 which I use in my current project.
Let me another example.
CREATE OR REPLACE PACKAGE rds_mdt_test IS
TYPE TTab0 IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
TYPE TRec1 IS RECORD(
NAME VARCHAR2(4000),
rows TTab0);
TYPE TTab1 IS TABLE OF TRec1 INDEX BY BINARY_INTEGER;
TYPE TRec2 IS RECORD(
NAME VARCHAR2(4000),
rows TTab1);
TYPE TTab2 IS TABLE OF TRec2 INDEX BY BINARY_INTEGER;
TYPE TStrTab IS TABLE OF NUMBER INDEX BY VARCHAR2(256);
PROCEDURE test_plsql_table(cnt INTEGER);
PROCEDURE test_str_tab(cnt INTEGER);
x TTab2;
empty_tab2 TTab2;
empty_tab1 TTab1;
empty_tab0 TTab0;
str_tab TStrTab;
empty_str_tab TStrTab;
END rds_mdt_test;
CREATE OR REPLACE PACKAGE BODY rds_mdt_test IS
PROCEDURE test_plsql_table(cnt INTEGER) IS
BEGIN
FOR indx1 IN 1 .. cnt LOOP
FOR indx2 IN 1 .. cnt LOOP
FOR indx3 IN 1 .. cnt LOOP
x(indx1) .rows(indx2) .rows(indx3) := indx1;
END LOOP;
END LOOP;
END LOOP;
x := empty_tab2;
dbms_session.free_unused_user_memory;
END;
PROCEDURE test_str_tab(cnt INTEGER) IS
BEGIN
FOR indx IN 1 .. cnt LOOP
str_tab(indx) := indx;
END LOOP;
str_tab := empty_str_tab;
dbms_session.free_unused_user_memory;
END;
END rds_mdt_test;
1. Running the script
BEGIN
rds_mdt_test.test_plsql_table ( 100 );
END;
I see that usage of PGA memory in my session is close to zero. So, I can judge that nested PL/SQL table indexed by BINARY_INTEGER and the memory allocated to it were cleaned successfully.
2. Running the script
BEGIN
rds_mdt_test.test_str_tab ( 1000000 );
END;
I can see that plain PL/SQL table indexed by VARCHAR2 and memory allocated to it were cleaned also.
3. Changing the package's type
TYPE TTab2 IS TABLE OF TRec2 INDEX BY VARCHAR2(256);
and running the script
BEGIN
rds_mdt_test.test_plsql_table ( 100 );
END;
I see that my session uses about 62M in PGA. If I run this script twice, the memory usage is doubled and so on.
The same result I get if I rewrite not highest, but middle PL/SQL type:
TYPE TTab1 IS TABLE OF TRec1 INDEX BY VARCHAR2(256);
And only if I change the third, most nested type:
TYPE TTab0 IS TABLE OF NUMBER INDEX BY VARCHAR2(256);
I get the desired result -- all memory was returned to OS.
So, as far as I can judge, in some cases Oracle does not clean complex PL/SQL tables indexed by VARCHAR2.
Is it true or not? Perhaps there are some features in using such way indexed tables? -
Using the Insert statement in a Java program without hardcoding the data
hello.
this is james mcfadden. i have developed a program called Demo.java, which is used with another program called QueryTableModel.java (a program that allows data to be viewed in a JTable). The Demo.java program displays a menu, connects to a database, allows the user to add data into the database and allows the user to view data that is already in the database. I have a problem with the Demo.java program. I have hardcoded the Insert statement in it. How do you use the Insert statement to put data into a database without hardcoding the data?
import java.awt.*;//Contains all of the classes for creating user interfaces and for painting graphics and images
import java.awt.event.*;//Provides interfaces and classes for dealing with different types of events fired by AWT components
import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms
import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable
import javax.swing.JOptionPane;//provides a class that makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something
import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language
public class Demo extends JFrame{
static String url = "jdbc:odbc:VideoLibrary";//a static variable that allows a connection to be made to a database called VideoLibrary
static Statement stmt;//a static variable that allows a statement to be made once a connection is set up
static Connection con;//a static interface that allows a connection to be made to a database
//global variables
JTextField hostField;//a class that allows a line of text to be changed
JTextField queryField;//a class that allows a line of text to be changed
QueryTableModel qtm;//a class that shows and changes regular two-dimensional tables of cells
JComboBox comboBox;//a class that puts a button or editable field and a drop-down list together
public static void main(String args[]){
int choice=-1;//a variable of type int that is set to -1
do{
choice=getChoice();//invokes the method getChoice()
if(choice!=0){
getSelected(choice);//invokes the method getSelected(choice)
}//end if
//if the user chooses 5, it will cause him or her to exit the system
}while(choice!=5);//end do-while
System.exit(0);//closes down the menu screen
}//end main
public static int getChoice(){
String choice;//a variable of type string
int ch;//a variable of type int
choice = JOptionPane.showInputDialog(null,"1. Maintain product details\n"+"2. Maintain member details\n"+"3. Maintain rental details\n"+"4. View product, member and rental details\n"+"5. Log Off\n\n"+"Enter your choice");//asks the user for some input
ch = Integer.parseInt(choice);//a class that wraps a value of the primitive type int in an object
return ch;//a method that returns an integer value
}//end getChoice
public static void getSelected(int choice){
if(choice==1){
maintainProductDetails();//invokes the method maintainProductDetails()
}//end if
if(choice==2){
maintainMemberDetails();//invokes the method maintainMemberDetails()
}//end if
if(choice==3){
maintainRentalDetails();//invokes the method maintainRentalDetails()
}//end if
if(choice==4){
Demo test = new Demo();//invokes the constructor Demo()
test.setVisible(true);//shows the JTable component by marking it as visible
}//end if
}//end getSelected
public static Connection getConnection(){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used to create a JDBC connection using a database
}//end try
catch(java.lang.ClassNotFoundException e){//causes an exception to be thrown when an application tries to load in a class through its string name
System.err.print("ClassNotFoundException: ");//displays an error message
System.err.println(e.getMessage());//returns the exception that was raised if an error occurred while attempting to load the ClassNotFoundException class
}//end catch
try {
con=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class
}//end try
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
}//end catch
return con;
}//end getConnection
public static void maintainProductDetails(){
Connection con = getConnection();//creates a connection with the database
String addProduct1, addProduct2, addProduct3, addProduct4, addProduct5, addProduct6, addProduct7, addProduct8, addProduct9, addProduct10;//string variables that represent information about the different types of product data that will be stored in the database
addProduct1 = "insert into Product values (110001, 'The Killers - Sams Town', 5.00, 'G', 'CD', 2006)";
addProduct2 = "insert into Product values (110002, 'Robbie Williams - Rudebox', 5.00, 'G', 'CD', 2006)";
addProduct3 = "insert into Product values (110003, 'Razorlight - Razorlight', 5.00, 'G', 'CD', 2006)";
addProduct4 = "insert into Product values (110004, 'My Chemical Romance - The Black Parade', 5.00, 'G', 'CD', 2006)";
addProduct5 = "insert into Product values (110005, 'Snow Patrol - Eyes Open', 5.00, 'G', 'CD', 2006)";
addProduct6 = "insert into Product values (110006, 'Scissor Sisters - Ta-Dah!', 5.00, 'G', 'CD', 2006)";
addProduct7 = "insert into Product values (110007, 'Lovesounds - Justin Timberlake', 5.00, 'G', 'CD', 2006)";
addProduct8 = "insert into Product values (110008, 'Director - We thrive on big cities', 5.00, 'G', 'CD', 2006)";
addProduct9 = "insert into Product values (110009, 'Roxette - Roxette hits', 5.00, 'G', 'CD', 2006)";
addProduct10 = "insert into Product values (110010, 'Pussy Cat Dolls - PCD', 5.00, 'G', 'CD', 2006)";
try {
stmt = con.createStatement();//Creates a Statement object for sending SQL statements to the database
//statements are allowed to be made once a connection is set up
stmt.executeUpdate(addProduct1);
stmt.executeUpdate(addProduct2);
stmt.executeUpdate(addProduct3);
stmt.executeUpdate(addProduct4);
stmt.executeUpdate(addProduct5);
stmt.executeUpdate(addProduct6);
stmt.executeUpdate(addProduct7);
stmt.executeUpdate(addProduct8);
stmt.executeUpdate(addProduct9);
stmt.executeUpdate(addProduct10);
stmt.close();//closes the Statement object
con.close();//terminates the connection with the database
}//end try
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
}//end catch
}//end maintainProductDetails
public static void maintainMemberDetails(){
Connection con = getConnection();//creates a connection with the database
String addMember1, addMember2, addMember3, addMember4, addMember5, addMember6, addMember7, addMember8, addMember9, addMember10;//string variables that represent information about the member data that will be stored in the database
addMember1 = "insert into Member values (1234, 'Ann', 'Smyth', 'Upper Killult, Falcarragh, Co. Donegal', '(074)-9135210', '(087)-2030172', #5/11/85#, #5/12/06#)";
addMember2 = "insert into Member values (2345, 'John', 'Murphy', 'Lower Killult, Falcarragh, Co. Donegal', '(074)-9135211', '(087)-2030173', #4/12/85#, #6/13/06#)";
addMember3 = "insert into Member values (1324, 'James', 'McFadden', 'Lower Ardsbeg, Gortahork, Co. Donegal', '(074)-9165314', '(087)-2030171', #4/11/85#, #6/14/06#)";
addMember4 = "insert into Member values (1235, 'Frankie', 'Ferry', 'Ardsmore, Gortahork, Co. Donegal', '(074)-9165325', '(087)-2031234', #6/13/60#, #6/15/06#)";
addMember5 = "insert into Member values (1236, 'Daniel', 'McKimm', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135212', '(087)-2030184', #5/14/73#, #6/16/06#)";
addMember6 = "insert into Member values (2346, 'Stephen', 'Doohan', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135213', '(087)-2030185', #6/13/85#, #5/13/06#)";
addMember7 = "insert into Member values (2347, 'James', 'Ferry', 'Meenlaragh, Gortahork, Co.Donegal', '(074)-9165360', '(087)-2031345', #9/12/85#, #5/14/06#)";
addMember8 = "insert into Member values (2348, 'Liam', 'Cannon', 'Derryconner, Gortahork, Co.Donegal', '(074)-9165324', '(087)-2031456', #4/11/86#, #5/15/06#)";
addMember9 = "insert into Member values (2401, 'Ciaran', 'Ferry', 'Brinalack, Gweedore, Co.Donegal', '(074)-9176425', '(087)-2030282', #9/12/85#, #5/16/06#)";
addMember10 = "insert into Member values (2402, 'Ciaran', 'McGee', 'Derrybeg, Gweedore, Co.Donegal', '(074)-9176536', '(087)-2030393', #9/14/85#, #5/18/06#)";
try{
stmt = con.createStatement();//Creates a Statement object for sending SQL statements to the database
//statements are allowed to be made once a connection is set up
stmt.executeUpdate(addMember1);
stmt.executeUpdate(addMember2);
stmt.executeUpdate(addMember3);
stmt.executeUpdate(addMember4);
stmt.executeUpdate(addMember5);
stmt.executeUpdate(addMember6);
stmt.executeUpdate(addMember7);
stmt.executeUpdate(addMember8);
stmt.executeUpdate(addMember9);
stmt.executeUpdate(addMember10);
stmt.close();//closes the Statement object
con.close();//terminates the connection with the database
}//end try
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
}//end catch
}//end maintainMemberDetails
public static void maintainRentalDetails(){
Connection con = getConnection();//creates a connection with the database
String addRental1, addRental2, addRental3, addRental4, addRental5, addRental6, addRental7, addRental8, addRental9, addRental10;//string variables that represent information about the loan data that will be stored in the database
addRental1 = "insert into Rental values (110001, 'The Killers - Sams Town', 1234, 'Ann', 'Smyth', #9/01/06#, #9/10/06#, 'Yes', 2.00)";
addRental2 = "insert into Rental values (120001, 'Mission Impossible 3', 2345, 'John', 'Murphy', #9/02/06#, #9/09/06#, 'No', 0.00)";
addRental3 = "insert into Rental values (130001, 'Need for Special Carbon', 1324, 'James', 'McFadden', #9/03/06#, #9/12/06#, 'Yes', 2.00)";
addRental4 = "insert into Rental values (110002, 'Robbie Williams - Rudebox', 1235, 'Frankie', 'Ferry', #9/04/06#, #9/11/06#, 'No', 0.00)";
addRental5 = "insert into Rental values (120015, 'Prime', 1236, 'Daniel', 'McKimm', #9/05/06#, #9/14/06#, 'Yes', 2.00)";
addRental6 = "insert into Rental values (130015, 'FIFA 07', 2346, 'Stephen', 'Doohan', #9/06/06#, #9/13/06#, 'No', 0.00)";
addRental7 = "insert into Rental values (110009, 'Roxette - Roxette hits', 2347, 'James', 'Ferry', #9/07/06#, #9/16/06#, 'Yes', 2.00)";
addRental8 = "insert into Rental values (120003, 'The Break Up', 2348, 'Liam', 'Cannon', #9/08/06#, #9/15/06#, 'No', 0.00)";
addRental9 = "insert into Rental values (130027, 'Gears of War', 2401, 'Ciaran', 'Ferry', #9/09/06#, #9/18/06#, 'Yes', 2.00)";
addRental10 = "insert into Rental values (110021, 'Scooter - Mind the Gap', 2402, 'Ciaran', 'McGee', #9/10/06#, #9/17/06#, 'No', 0.00)";
try{
stmt = con.createStatement();//Creates a Statement object for sending SQL statements to the database
//statements are allowed to be made once a connection is set up
stmt.executeUpdate(addRental1);
stmt.executeUpdate(addRental2);
stmt.executeUpdate(addRental3);
stmt.executeUpdate(addRental4);
stmt.executeUpdate(addRental5);
stmt.executeUpdate(addRental6);
stmt.executeUpdate(addRental7);
stmt.executeUpdate(addRental8);
stmt.executeUpdate(addRental9);
stmt.executeUpdate(addRental10);
stmt.close();//closes the Statement object
con.close();//terminates the connection with the database
}//end try
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
}//end catch
}//end maintainRentalDetails
public Demo(){//a constructor
super("Demo Test Frame");//overrides the constructor
setSize(350, 200);//Resizes this component so that it has width of 350 and height of 200
comboBox = new JComboBox();//invokes the class JComboBox
comboBox.addItem("jdbc:odbc:VideoLibrary");//adds the specified item to the end of the scrolling list
qtm = new QueryTableModel();//invokes the class QueryTableModel
JTable table = new JTable(qtm);//a class that shows and changes regular two-dimensional tables of cells
JScrollPane scrollpane = new JScrollPane(table);//a class that provides a scrollable view of a lightweight component
JPanel p1 = new JPanel();//a class that puts the combo box and query field in a panel
p1.setLayout(new GridLayout(3, 2));//Sets the layout manager for this container
p1.add(comboBox);//Appends the specified component to the end of this container
p1.add(new JLabel("Enter your query: "));//Appends the specified component to the end of this container
p1.add(queryField = new JTextField());//Appends the specified component to the end of this container
p1.add(new JLabel("Click here to send: "));//Appends the specified component to the end of this container
JButton jb = new JButton("Search");//a class that is an implementation of a "push" button
jb.addActionListener(new ActionListener(){//Adds an ActionListener to the button
public void actionPerformed(ActionEvent e){
qtm.setHostURL();//invokes the method setHostURL
qtm.setQuery(queryField.getText().trim());//invokes the method setQuery; and returns the text that is presented by this text component and returns a copy of the string, with leading and trailing whitespaces omitted
} );//end addActionListener
p1.add(jb);//Appends the specified component to the end of this container
getContentPane().add(p1, BorderLayout.NORTH);//Returns the content pane
getContentPane().add(scrollpane, BorderLayout.CENTER);//Returns the content pane
}//end Demo
}//end class Demo
import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language
import java.io.*;//Provides for system input and output through data streams, serialization and the file system
import java.util.Vector;//provides a class that implements a growable array of objects
import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms
import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable
public class QueryTableModel extends AbstractTableModel{
Vector cache;//a class that constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
int colCount;//a variable that counts the number of columns in the three tables
String[] headers;//a class that represents character strings and all string literals in this program are implemented as instances of the String class
Connection db;//an interface that allows a connection to be made to a database
Statement statement;//an interface that allows executes the given SQL statement, which returns a single ResultSet object
String currentURL;//a variable that allows the URL to be displayed in a combo box
public QueryTableModel(){//a constructor
cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used by opening a JDBC connection using an URL
}//end try
catch(Exception e){
System.out.println("problem loading the driver ");//an error message
}//end catch
}//end QueryTableModel
public String getColumnName(int i){//Returns the designated column's name
return headers;//returns the name of each column in the three table
}//end getColumnName
public int getColumnCount(){//Returns the number of columns in the column model
return colCount;//returns the number of columns in the three tables
}//end getColumnCount
public int getRowCount(){//Returns the number of rows in this table's model
return cache.size();//returns the number of components in the vector
}//end getRowCount
public Object getValueAt(int row, int col){//Returns the cell value at row and column
return ((String[])cache.elementAt(row))[col];//Returns the component at the specified index
}//end getValueAt
public void setHostURL(){//sets the URL for the database
String url = "jdbc:odbc:VideoLibrary";//a variable that allows a connection to be made to a database called VideoLibrary
closeDB();//invokes the method closeDB()
try{
db=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class
statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database
}//end try
catch(Exception e){
System.out.println("Could not initialize the database.");//an error message
e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
}//end catch
}//end setHostURL
public void setQuery(String q){//sets the kind of query that is to be sent to the database
cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
String s="select * from Product";//a variable that causes all the data that is in the product table to be displayed in a JTable, which also means that all the data that is in both the member and rental tables can also be displayed in a JTable
try{
ResultSet rs=statement.executeQuery(q);//an interface that is used to generate a database result set by executing a statement that queries the database
ResultSetMetaData meta=rs.getMetaData();//an interface that is used to get information about the types and properties of the columns in a ResultSet object
colCount=meta.getColumnCount();//Returns the number of columns in this ResultSet object
headers=new String[colCount];//gets the name of each column in the three tables
for(int h=1;h<=colCount;h++){
headers[h-1]=meta.getColumnName(h);//Get the designated column's name
}//end for
while(rs.next()){
String[] record=new String[colCount];//stores the name of each column in the three tables in memory
for(int i=0;i<colCount;i++){
record[i]=rs.getString(i+1);//Retrieves the value of the designated column in the current row of this ResultSet object as a String
}//end for
cache.addElement(record);//Adds the specified component to the end of this vector, increasing its size by one
}//end while
fireTableChanged(null);//Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model
}//end try
catch(Exception e){
cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
}//end catch
}//end setQuery
public void initDB(String url){
try{
db=DriverManager.getConnection(url);//tries to create a connection with the database using the DriverManager class
statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database
}//end try
catch(Exception e){
System.out.println("Could not initialize the database.");//an error message
e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
}//end catch
}//end initDB
public void closeDB(){
try{
if(statement!=null){
statement.close();//Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed
}//end if
if(db!=null){
db.close();//Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released
}//end if
}//end try
catch(Exception e){
System.out.println("Could not close the current connection.");//an error message
e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
}//end catch
}//end closeDB
}//end class QueryTableModelhere's an uncommented version of the code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.JOptionPane;
import java.sql.*;
public class Demo extends JFrame{
static String url = "jdbc:odbc:VideoLibrary";
static Statement stmt;
static Connection con;
JTextField hostField;
JTextField queryField;
QueryTableModel qtm;
JComboBox comboBox;
public static void main(String args[]){
int choice=-1;
do{
choice=getChoice();
if(choice!=0){
getSelected(choice);
}while(choice!=5);
System.exit(0);
public static int getChoice(){
String choice;
int ch;
choice = JOptionPane.showInputDialog(null,"1. Maintain product details\n"+"2. Maintain member details\n"+"3. Maintain rental details\n"+"4. View product, member and rental details\n"+"5. Log Off\n\n"+"Enter your choice");
ch = Integer.parseInt(choice);
return ch;
public static void getSelected(int choice){
if(choice==1){
maintainProductDetails();
if(choice==2){
maintainMemberDetails();
if(choice==3){
maintainRentalDetails();
if(choice==4){
Demo test = new Demo();
test.setVisible(true);
public static Connection getConnection(){
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(java.lang.ClassNotFoundException e){
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
try {
con=DriverManager.getConnection(url,"","");
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
return con;
public static void maintainProductDetails(){
Connection con = getConnection();
String addProduct1, addProduct2, addProduct3, addProduct4, addProduct5, addProduct6, addProduct7, addProduct8, addProduct9, addProduct10;
addProduct1 = "insert into Product values (110001, 'The Killers - Sams Town', 5.00, 'G', 'CD', 2006)";
addProduct2 = "insert into Product values (110002, 'Robbie Williams - Rudebox', 5.00, 'G', 'CD', 2006)";
addProduct3 = "insert into Product values (110003, 'Razorlight - Razorlight', 5.00, 'G', 'CD', 2006)";
addProduct4 = "insert into Product values (110004, 'My Chemical Romance - The Black Parade', 5.00, 'G', 'CD', 2006)";
addProduct5 = "insert into Product values (110005, 'Snow Patrol - Eyes Open', 5.00, 'G', 'CD', 2006)";
addProduct6 = "insert into Product values (110006, 'Scissor Sisters - Ta-Dah!', 5.00, 'G', 'CD', 2006)";
addProduct7 = "insert into Product values (110007, 'Lovesounds - Justin Timberlake', 5.00, 'G', 'CD', 2006)";
addProduct8 = "insert into Product values (110008, 'Director - We thrive on big cities', 5.00, 'G', 'CD', 2006)";
addProduct9 = "insert into Product values (110009, 'Roxette - Roxette hits', 5.00, 'G', 'CD', 2006)";
addProduct10 = "insert into Product values (110010, '***** Cat Dolls - PCD', 5.00, 'G', 'CD', 2006)";
try {
stmt = con.createStatement();
stmt.executeUpdate(addProduct1);
stmt.executeUpdate(addProduct2);
stmt.executeUpdate(addProduct3);
stmt.executeUpdate(addProduct4);
stmt.executeUpdate(addProduct5);
stmt.executeUpdate(addProduct6);
stmt.executeUpdate(addProduct7);
stmt.executeUpdate(addProduct8);
stmt.executeUpdate(addProduct9);
stmt.executeUpdate(addProduct10);
stmt.close();
con.close();
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
public static void maintainMemberDetails(){
Connection con = getConnection();
String addMember1, addMember2, addMember3, addMember4, addMember5, addMember6, addMember7, addMember8, addMember9, addMember10;
addMember1 = "insert into Member values (1234, 'Ann', 'Smyth', 'Upper Killult, Falcarragh, Co. Donegal', '(074)-9135210', '(087)-2030172', #5/11/85#, #5/12/06#)";
addMember2 = "insert into Member values (2345, 'John', 'Murphy', 'Lower Killult, Falcarragh, Co. Donegal', '(074)-9135211', '(087)-2030173', #4/12/85#, #6/13/06#)";
addMember3 = "insert into Member values (1324, 'James', 'McFadden', 'Lower Ardsbeg, Gortahork, Co. Donegal', '(074)-9165314', '(087)-2030171', #4/11/85#, #6/14/06#)";
addMember4 = "insert into Member values (1235, 'Frankie', 'Ferry', 'Ardsmore, Gortahork, Co. Donegal', '(074)-9165325', '(087)-2031234', #6/13/60#, #6/15/06#)";
addMember5 = "insert into Member values (1236, 'Daniel', 'McKimm', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135212', '(087)-2030184', #5/14/73#, #6/16/06#)";
addMember6 = "insert into Member values (2346, 'Stephen', 'Doohan', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135213', '(087)-2030185', #6/13/85#, #5/13/06#)";
addMember7 = "insert into Member values (2347, 'James', 'Ferry', 'Meenlaragh, Gortahork, Co.Donegal', '(074)-9165360', '(087)-2031345', #9/12/85#, #5/14/06#)";
addMember8 = "insert into Member values (2348, 'Liam', 'Cannon', 'Derryconner, Gortahork, Co.Donegal', '(074)-9165324', '(087)-2031456', #4/11/86#, #5/15/06#)";
addMember9 = "insert into Member values (2401, 'Ciaran', 'Ferry', 'Brinalack, Gweedore, Co.Donegal', '(074)-9176425', '(087)-2030282', #9/12/85#, #5/16/06#)";
addMember10 = "insert into Member values (2402, 'Ciaran', 'McGee', 'Derrybeg, Gweedore, Co.Donegal', '(074)-9176536', '(087)-2030393', #9/14/85#, #5/18/06#)";
try{
stmt = con.createStatement();
stmt.executeUpdate(addMember1);
stmt.executeUpdate(addMember2);
stmt.executeUpdate(addMember3);
stmt.executeUpdate(addMember4);
stmt.executeUpdate(addMember5);
stmt.executeUpdate(addMember6);
stmt.executeUpdate(addMember7);
stmt.executeUpdate(addMember8);
stmt.executeUpdate(addMember9);
stmt.executeUpdate(addMember10);
stmt.close();
con.close();
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
public static void maintainRentalDetails(){
Connection con = getConnection();
String addRental1, addRental2, addRental3, addRental4, addRental5, addRental6, addRental7, addRental8, addRental9, addRental10;
addRental1 = "insert into Rental values (110001, 'The Killers - Sams Town', 1234, 'Ann', 'Smyth', #9/01/06#, #9/10/06#, 'Yes', 2.00)";
addRental2 = "insert into Rental values (120001, 'Mission Impossible 3', 2345, 'John', 'Murphy', #9/02/06#, #9/09/06#, 'No', 0.00)";
addRental3 = "insert into Rental values (130001, 'Need for Special Carbon', 1324, 'James', 'McFadden', #9/03/06#, #9/12/06#, 'Yes', 2.00)";
addRental4 = "insert into Rental values (110002, 'Robbie Williams - Rudebox', 1235, 'Frankie', 'Ferry', #9/04/06#, #9/11/06#, 'No', 0.00)";
addRental5 = "insert into Rental values (120015, 'Prime', 1236, 'Daniel', 'McKimm', #9/05/06#, #9/14/06#, 'Yes', 2.00)";
addRental6 = "insert into Rental values (130015, 'FIFA 07', 2346, 'Stephen', 'Doohan', #9/06/06#, #9/13/06#, 'No', 0.00)";
addRental7 = "insert into Rental values (110009, 'Roxette - Roxette hits', 2347, 'James', 'Ferry', #9/07/06#, #9/16/06#, 'Yes', 2.00)";
addRental8 = "insert into Rental values (120003, 'The Break Up', 2348, 'Liam', 'Cannon', #9/08/06#, #9/15/06#, 'No', 0.00)";
addRental9 = "insert into Rental values (130027, 'Gears of War', 2401, 'Ciaran', 'Ferry', #9/09/06#, #9/18/06#, 'Yes', 2.00)";
addRental10 = "insert into Rental values (110021, 'Scooter - Mind the Gap', 2402, 'Ciaran', 'McGee', #9/10/06#, #9/17/06#, 'No', 0.00)";
try{
stmt = con.createStatement();
stmt.executeUpdate(addRental1);
stmt.executeUpdate(addRental2);
stmt.executeUpdate(addRental3);
stmt.executeUpdate(addRental4);
stmt.executeUpdate(addRental5);
stmt.executeUpdate(addRental6);
stmt.executeUpdate(addRental7);
stmt.executeUpdate(addRental8);
stmt.executeUpdate(addRental9);
stmt.executeUpdate(addRental10);
stmt.close();
con.close();
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
public Demo(){
super("Demo Test Frame");
setSize(350, 200);
comboBox = new JComboBox();
comboBox.addItem("jdbc:odbc:VideoLibrary");
qtm = new QueryTableModel();
JTable table = new JTable(qtm);
JScrollPane scrollpane = new JScrollPane(table);
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(3, 2));
p1.add(comboBox);
p1.add(new JLabel("Enter your query: "));
p1.add(queryField = new JTextField());
p1.add(new JLabel("Click here to send: "));
JButton jb = new JButton("Search");
jb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
qtm.setHostURL();
qtm.setQuery(queryField.getText().trim());
p1.add(jb);
getContentPane().add(p1, BorderLayout.NORTH);
getContentPane().add(scrollpane, BorderLayout.CENTER);
import java.sql.*;
import java.io.*;
import java.util.Vector;
import javax.swing.*;
import javax.swing.table.*;
public class QueryTableModel extends AbstractTableModel{
Vector cache;
int colCount;
String[] headers;
Connection db;
Statement statement;
String currentURL;
public QueryTableModel(){
cache=new Vector();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(Exception e){
System.out.println("problem loading the driver ");
public String getColumnName(int i){
return headers;
public int getColumnCount(){
return colCount;
public int getRowCount(){
return cache.size();
public Object getValueAt(int row, int col){
return ((String[])cache.elementAt(row))[col];
public void setHostURL(){
String url = "jdbc:odbc:VideoLibrary";
closeDB();
try{
db=DriverManager.getConnection(url,"","");
statement=db.createStatement();
catch(Exception e){
System.out.println("Could not initialize the database.");
e.printStackTrace();
public void setQuery(String q){
cache=new Vector();
String s="select * from Product";
try{
ResultSet rs=statement.executeQuery(q);
ResultSetMetaData meta=rs.getMetaData();
colCount=meta.getColumnCount();
headers=new String[colCount];
for(int h=1;h<=colCount;h++){
headers[h-1]=meta.getColumnName(h);
while(rs.next()){
String[] record=new String[colCount];
for(int i=0;i<colCount;i++){
record[i]=rs.getString(i+1);
cache.addElement(record);
fireTableChanged(null);
catch(Exception e){
cache=new Vector();
e.printStackTrace();
public void initDB(String url){
try{
db=DriverManager.getConnection(url);
statement=db.createStatement();
catch(Exception e){
System.out.println("Could not initialize the database.");
e.printStackTrace();
public void closeDB(){
try{
if(statement!=null){
statement.close();
if(db!=null){
db.close();
catch(Exception e){
System.out.println("Could not close the current connection.");
e.printStackTrace(); -
How do i use an import statement in a java program
I need to write a java program which will connect to the Database but i need to do an import like in DB2 which will load data to the table.
How do i execute that import statementAre you saying that you need to add rows to a table in DB2 via a Java program? If so, you need to look at the JDBC API, (available on this site along with a bunch of tutorials). If not, post again with a clearer description of your problem.
-
Using PL/SQL Table in Forms
Hi,
I am populating a PL/SQL table by fetching data through a explicit cursor. But when i am accessing the PL/SQL table after population, i am getting a "NO DATA FOUND" error.
I am attaching the Forms local progam units which have the logic.
PACKAGE f_get_bike_makers IS
TYPE prectype_maker_dtls_pll IS RECORD (
country_code ad_bike_maker_details.abmd_country_code%TYPE,
country_name table_values.tvs_description%TYPE,
manu_code ad_bike_maker_details.abmd_manufacturer_code%TYPE,
maker_name ad_bike_maker_details.abmd_maker_name%TYPE,
maker_name_kana ad_bike_maker_details.abmd_maker_name_kana%TYPE,
const_by ad_bike_maker_details.abmd_constructed_by%TYPE,
const_time ad_bike_maker_details.abmd_construction_time%TYPE,
update_by ad_bike_maker_details.abmd_updated_by%TYPE,
update_time ad_bike_maker_details.abmd_updated_time%TYPE
TYPE ptabtype_maker_dtls_pll IS TABLE OF prectype_maker_dtls_pll
INDEX BY BINARY_INTEGER;
FUNCTION f_get_bike_makers_pll RETURN ptabtype_maker_dtls_pll;
END;
PACKAGE BODY f_get_bike_makers IS
FUNCTION f_get_bike_makers_pll
RETURN ptabtype_maker_dtls_pll
IS
CURSOR cur_maker_dtls
IS
SELECT abmd.abmd_country_code,
tvs.tvs_description,
abmd.abmd_manufacturer_code,
abmd.abmd_maker_name,
abmd.abmd_maker_name_kana,
abmd.abmd_constructed_by,
abmd.abmd_construction_time,
abmd.abmd_updated_by,
abmd.abmd_updated_time
FROM ad_bike_maker_details abmd,
table_values tvs
WHERE abmd.abmd_country_code = tvs.tvs_code
AND tvs.tvs_tad_code = 'COUNTRIES'
ORDER BY abmd.abmd_country_code;
ln_tab_index BINARY_INTEGER := 0;
ltab_maker_dtls ptabtype_maker_dtls_pll;
BEGIN
FOR lcur_maker_dtls IN cur_maker_dtls
LOOP
ln_tab_index := ln_tab_index + 1;
ltab_maker_dtls (ln_tab_index) := lcur_maker_dtls;
END LOOP;
RETURN ltab_maker_dtls;
END f_get_bike_makers_pll;
END;
PROCEDURE f_populate_maker_names
IS
ltab_maker_dtls f_get_bike_makers.ptabtype_maker_dtls_pll;
lb_record_group BOOLEAN;
ln_ltab_maker_dtls_index BINARY_INTEGER;
BEGIN
-- read all the vehicle types from table_values
-- get makers and countries
ltab_maker_dtls := f_get_bike_makers.f_get_bike_makers_pll ;
DELETE_GROUP_ROW ('REC_MAKER_NAME', all_rows);
ln_ltab_maker_dtls_index := ltab_maker_dtls.FIRST;
begin
WHILE ln_ltab_maker_dtls_index IS NOT NULL
LOOP
lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
'ABMD_MANUFACTURER_CODE',
ltab_maker_dtls (ln_ltab_maker_dtls_index).manu_code,
ln_ltab_maker_dtls_index
lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
'ABMD_MAKER_NAME',
ltab_maker_dtls (ln_ltab_maker_dtls_index).maker_name,
ln_ltab_maker_dtls_index
lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
'COUNTRY_NAME',
ltab_maker_dtls (ln_ltab_maker_dtls_index).country_name,
ln_ltab_maker_dtls_index
lb_record_group := l_record_group.insert_value ('REC_MAKER_NAME',
'ABMD_COUNTRY_CODE',
ltab_maker_dtls (ln_ltab_maker_dtls_index).country_code,
ln_ltab_maker_dtls_index
ln_ltab_maker_dtls_index := ltab_maker_dtls.NEXT (ln_ltab_maker_dtls_index);
end;
END LOOP;
exception when no_data_found then
message('ln_ltab_maker_dtls_index :'||ln_ltab_maker_dtls_index);
message(' ');
end;
ltab_maker_dtls.DELETE;
END;
SQL> desc ad_bike_maker_details
Name Null? Type
ABMD_COUNTRY_CODE NOT NULL VARCHAR2(2)
ABMD_MANUFACTURER_CODE NOT NULL VARCHAR2(2)
ABMD_MAKER_NAME VARCHAR2(60)
ABMD_MAKER_NAME_KANA VARCHAR2(60)
ABMD_CONSTRUCTED_BY NOT NULL VARCHAR2(20)
ABMD_CONSTRUCTION_TIME NOT NULL DATE
ABMD_UPDATED_BY VARCHAR2(20)
ABMD_UPDATED_TIME DATE
SQL> desc table_values
Name Null? Type
TVS_TAD_CODE NOT NULL VARCHAR2(15)
TVS_CODE NOT NULL VARCHAR2(15)
TVS_DESCRIPTION NOT NULL VARCHAR2(70)
Oracle Database Version
=======================
Oracle8 Enterprise Edition Release 8.0.6.1.0 - Production
PL/SQL Release 8.0.6.1.0 - Production
Forms Version
==============
Forms [32 Bit] Version 5.0.6.8.0 (Production)
PL/SQL Version 2.3.4.0.0 (Production)
Please do let know what could be the possible source of error.
Thanks in advance.
NitinBut we have to use the PL/SQL table as per our design standards.
We are implementing the population logic of the PL/SQL table in the database as a
package function. We are then accessing the PL/SQL table in Forms to populate the record group.It is curious that you would have such a unique requirement -- something that might make forms run a tiny bit faster -- yet you are using an ancient version of Forms.
Also the "NO DATA FOUND" error is not raised everytime the PL/SQL table is accessed.
What could be the reason for this erratic behaviour?I wonder if there may be a bug in SQL Net in the Oracle-to-Forms communication where PL/SQL tables are passed as out parameters. I know there is one in Web Forms 6 (6.0.8.19.1) when passing a pl/sql table from the form to Oracle -- I had to write the pl/sql table to a database table to get my process to work. -
To generate a wsdl using JAX-WS in JBOSS with java program but without EJB
Hi,
I am using JAX-WS to generate webservices using JBOSS application server by writing a java program.
My sample java program includes :which takes an i/p name as string and displays out put as "Hello name",with the use of annotations.And,also have written web.xml for it.If I start JBOSS without adding project to it,it is starting.BUt If I add project to it the server is not publishing.Its getting like:"publishing JBOSS 4.2.2....:waiting for virtual machine to exit".
I have followed the link:*http://www.javabeat.net/articles/2007/10/creating-webservice-using-jboss-and-eclipse/3*
to do this,where in it was given that by means of auto build process of eclipse IDE war file generates in default jboss folder.But which is not happening,so that,am unable to generate wsdl file..
Can any body help me?
1) why jboss is not publishing after adding project to it?
2) why war file is not generating in the default jboss folder?
Regards....Yeah sure!!
Overall picture: I wish to expose my OSB services to the third parties using OCSG. For that I've created the Communication services corresponding to each OSB service.
Problem: Integration with the OSB.
At the OSB side I've got JMS queues which interacts with other existing systems in my SOA enviornment. But I'm not getting how to get the OCSG application- triggered request messages in that queue? Please help.
Also I've read about the SOA facades for integration with OSB.Which of the two approaches you will suggest? -
Accessing Sql Server from AS400 Java program
Hi everybody,
I am trying to access Sql Server from an AS400 Java program. I have tried various Sql Server JDBC drivers including the Microsoft one but no luck yet. When i try to compile my Java program (with driver file in the classpath) it gives some errors on the driver jar file and also it throws out lots of unreadable text characters. This gave me a feeling that probably its a character coding issue with the jar file, so i tried ftp the file in binary mode as well as copying through the Operations Navigator. But still compilation is giving the same kind of errors.
Do I need to have some special JDBC Drivers compiled for AS400 specifically. My understanding was that Java is platform independent so any JDBC Type 4 driver will work.
We are running Java 1.3 on the AS400. Any help on this issue would be great.
Thanks
InderThanks for the help. I am writing a Java program after a long time that's why was making that mistake. Now the program gets compiled correctly but on running the program i am getting the following error message:
java 001-0070: Exception JVAB544 not expected
/myjava/test/msbase.jar: 001-0050 Syntax error on Line 1: token ')' not expected
/myjava/test/msutil.jar: 001-0050 Syntax error on Line 1: token ')' not expected
/myjava/test/mssqlserver.jar: 001-0050 Syntax error on Line 1: token ')' not expected
I have no idea what is this error about. Though the same driver files don't give any error when running on a Windows machine.
Thanks -
Design question on using PL/SQL table
Hi I am doing some data extract and write it to a file. The main table is over 100 million rows. It is is partition by ID. So I am thinking of paralleling it.
We are on 10g so we can not use the dbms_parallel.
I would like to use dbms_scheduler or the table function like the Oracle MapReduce example
However, I am not quite sure how to control the degree of parallism using the Oracle MapReduce
Moreover the company has the own unix scheduler and I am 90% sure the old-timer would shoot down my idea and urge to use the in-house built scheduler to this kind of parallel job.
So I would create a procedure that takes a list of ID and then run the extract, write out the file
and this procedure will call by sqlplus on unix.
Once all the threads are done, then the unix script will combine all the files produced into one file.
So my question is how to go about passing IN/OUT of the PL/SQL table and how I can put that PL/SQL table inside of a cursor
Can someone kind enough to give me some example/sample
-Thanks so muchHandle: vxwo0owxv
Status Level: Newbie
Registered: Mar 14, 2011
Total Posts: 88
Total Questions: 54 (39 unresolved)
Long on buzz words & short on knowledge to implement ideas!
vxwo0owxv wrote:
Hi I am doing some data extract and write it to a file. The main table is over 100 million rows. What % of rows need to be extracted?
Exactly how do plan on "write it to a file"?
It is is partition by ID. So I am thinking of paralleling it.Exactly what type of partitioning exists?
We are on 10g so we can not use the dbms_parallel.
I would like to use dbms_scheduler or the table function like the Oracle MapReduce examplepost URL to this MapReduce example
However, I am not quite sure how to control the degree of parallism using the Oracle MapReduce
Moreover the company has the own unix scheduler and I am 90% sure the old-timer would shoot down my idea and urge to use the in-house built scheduler to this kind of parallel job.
So I would create a procedure that takes a list of ID and then run the extract, write out the file
and this procedure will call by sqlplus on unix.Going back out to the OS just to access the DB induces overhead
>
Once all the threads are done, then the unix script will combine all the files produced into one file.
Does order of records in resultant file matter?
So my question is how to go about passing IN/OUT of the PL/SQL table and how I can put that PL/SQL table inside of a cursor
Pass from where to where?
Why PL/SQL table?
Realize that SQLPLUS knows nothing about PL/SQL table
Can someone kind enough to give me some example/sampleI could but then we'd both look unprofessional. -
Hi,
One my procedure's parameters is a PL/SQL table of id's (NUMBER) that the GUI sends it, based on the user's selections.
Now, I want to use the table's values in my select's where clause to return only the correct records.
However,
select ......
from ....
where id in (i_array_ids)
doesn't work of course, and my attempts of transfering the ids to a comma delimited list of numbers (as opposed to a lenghty varchar2 string) that could work between the ( ) have all failed.
ThanksAnd here's an example I gave with some more up-to-date syntax than in that old AskTom thread:
Re: DYNAMIC WHERE CLAUSE in PROCEDURE -
How to use an internal table of a calling program in to a called program
Hi Experts,
I am calling a report in another report through SUBMIT .
I want to use the internal table of calling prog into
called prog but problem is i have to do it without exporting to memory id and importing it.
Plz provide me any soln..Check for more information on SUBMIT
[http://www.sapdevelopment.co.uk/reporting/rep_submit.htm] -
How to use the internal table of the submitted program
Hi,
In the main program i have submitted a program and that program is running successfully and data is populated in to it_final, now i want to use this data populated internal table it_final in my main program.
Thanks,
Sudhakar.Hi,Mathew,
*& Report ZMB51 *
REPORT ZMB51 .
DATA LIST_TAB TYPE TABLE OF ABAPLIST.
DATA: BEGIN OF olist OCCURS 0,
filler1(1500) TYPE c,
END OF olist.
submit <b>RM07DOCS</b> EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = LIST_TAB
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC = 0.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1
TABLES
LISTASCI = oLIST
LISTOBJECT = LIST_TAB
EXCEPTIONS
EMPTY_LIST = 1
LIST_INDEX_INVALID = 2
OTHERS = 3.
BREAK-POINT.
write:/ sy-subrc.
ENDIF.
OLIST will contain the report output that you have executed but you need to tweak this internal table so that it can be used for further processing.The current example will get you MB51 output into OLIST,so change the program name to your program name at the SUBMIT statement and then try.
K.Kiran. -
Can LabVIEW variables be used like those found in a Java program?
I created a decoding program in Java that reads in a certain number, or code, and returns the decoded version of that number.
I tried initially to create this program inside of LabVIEW itself but was hindered by my lack of familiarity and knowledge of what LabVIEW can and can't do and how to approach the problem in LabVIEW.
My stumbling blocks in LabVIEW seem to be the arrays and working the variables. I'm probably approaching this completely wrong, more than likely because I'm trying to think in Java rather than LabVIEW.
Any help that can be given is most appreciated. Also I have attached a text document with my Java code in it. It's not perfect but it works.
If I need to clarify anything just ask.
Once again thanks for any help in advanced.
Solved!
Go to Solution.
Attachments:
Decoder.txt 5 KBIn LabVIEW the wire is the variable. The way you pass parameters to functions (subvis) is with a wire through the connector pane. Same for returning results.
Forget that local variables exist! A lot of new programmers that come from a text based programming background discover the LabVIEW local and global variables way too early. Like duct tape they can be useful. But it is possible to write huge complex applications without touching them. And the code is much simpler than programs of less complexity that make extensive use of locals and globals.
Since you are new to LabVIEW you can become a very good programmer if you keep the following in mind. It is a little confusing but "local variables" and "global variables" are not really variables in labVIEW like they are in Java. The wires are the variables. Those rectangle things you create from controls or indicators are more like a function for that control or indicator. They can not exist without an owning control or indicator. It is unfortunate that they are called variables but they are a relic of the stone ages when code was carved into cave walls.
=====================
LabVIEW 2012 -
*How can we use the internal table in module pool programming? Clarify plz*
If we creating a screen using the table having four fields(for e.g.). The screen has the functions of display, modify, delete, save, exit etc for the fields. The front-end of the screen having I/O fields of the table using internal table. How can we declare the internal table in the screen?
HI,
Create one WA for your Internal table and then map it to your fields.
For Example,
Data : begin of wa,
name(10),
age type i,
end of wa.
data : it like table of wa with header line.
Then in screen create input fields with the name, age and ***.
Then the user entered values are stored in name age and ***.
then you can manipulate with that values using wa.
Thanks.
Maybe you are looking for
-
Hi Friends. In extended classic scenario.In the first time if i create PO with attachment vai shopping cart (sourcing) successful purchase order is created and suppose if i change PO (qty/price etc) Then its Attached document is got deleted in SRM Ca
-
Selection Variant for Standard transaction
Hi, The requirement is that, On starting a standard transaction the initial selection screen should appear with a default selection variant selected in it. Regards, Prabaharan.G
-
NSPlaceholderMutableString initWithString nil argument I ordered one with no problem, but second one gets this error every time i place an order.
-
I am doing a podcast at http://joseph.libsyn.com. I had some complaints about the large file size, so in the latest episode "Neediness Management" I selected "Spoken Podcast/64Kb" under sound quality in the Advanced settings of GarageBand 3.0, down f
-
Hello all, I am comparing the DSEG data of a program in two different boxes in the debugger, and cannot find a way to export this data. Goto -> System -> System Areas -> DSEG. Is there is a way to export/print this data? I've done a thorough search o