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 statement
Are 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.
Similar Messages
-
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 to make use of a proxy for a java program
Hi all..
Instead of entering in command prompt
java -Dhttp proxyHost="255.255.255.255" -Dhttp.proxyPort ="XXXX" classname
how can we set the details in the program itself...
Any suggetions will be greatfull...Dhaval.Yoganandi wrote:
why do you think this is valueless ?Because they don't mean anything, can easily be gotten without writing good answers (cheating) and are usually rewarded by those who had the question and thus aren't in the best position to judge if an answer is a good one. -
SLD - import and Export through Java Program
Hi Exports,
Can you please guide how we can do SLD import and export through java program? additionally wanted to export Landscape(technical system,Landscape,business system),software catalog(products,s/w components),Development(Name Reservation)
Note: Manually we are doing through http://<server host>:<port>/sld and navigate into administration-->import and Export
Regards,
Manivannan Pclosed
-
How can i use one SQL statement to solve problem?
How can i use one SQL statement to solve the question below?
For a Table named A, there is a column named F(char type).
Now select all the records where F like '%00' and update their F value to '%01'
Just one SQL statement.Do not use PL/SQL block.
How to do that?
Thanks.What is the data volume for this table?
Do you expect lots of rows to have '%00' as their value?
Following two statements come to mind. Other experts would be able to provide better alternatives:
If you have index on SUBSTR(f, 2):
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) || '01'
WHERE substr(f,
-2) = '00';If most of the rows have pattern '%00':
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) ||
DECODE(SUBSTR(f,
-2),
'00',
'01',
SUBSTR(f,
-2)); -
How to make use of Windows authentication from my Java application
I have a Java application, Instead I design one more login page for my application, I want to make use of Windows Authentication.
How should I use that windows authentication in my java application
can any help me in suggesting a solutionHow will they be able to access your application if they aren't users of the system?
-
How can we calculate no. of instances in a java program ?
Hi,
I want to know that
How can we calculate no. of instances in a java program ?
Actually I just want to calculate number of live instances in a program at any time...
Thanx in Advance
VijayBeen asked a few times in this forum.
Try having a search.
One way, in brief, is to instrument your classes so that constructors update a per-type counter, and enqueue a PhantomReference for the instance.
When you pop from an associated ReferenceQueue, decrement the counter for the no longer reachable type.
Once you have this, you can query instance counts per type, or globably etc.
We maintain a model which can be remotely queried - and display results over time using JGraph. Gives a fairly non-intrusive way to spot and narrow down the cause of memory leaks in a large application. -
How do I use the CASE statement in the where clause?
Hello Everyone,
I have 2 queries that do what I need to do but I am trying to learn how to use the CASE statement.
I have tried to combine these 2 into one query using a case statement but don't get the results I need.
Could use some help on how to use the case syntax to get the results needed.
thanks a lot
select segment_name,
product_type,
count (distinct account_id)
FROM NL_ACCT
where
ind = 'N'
and
EM_ind = 'N'
and product_type in ('TAX','PAY')
and acct_open_dt between (cast('2006-01-17' as date)) and (cast('2006-01-17' as date) + 60)
GROUP BY 1,2
order by product_type
select segment_name,
product_type,
count (distinct account_id)
FROM NL_ACCT
where
ind = 'N'
and
EM_ind = 'N'
and product_type not in ('TAX','PAY')
and acct_open_dt between (cast('2006-01-17' as date)) and (cast('2006-01-17' as date) + 30)
group by 1,2
order by product_typeSomething like:
SELECT segment_name, product_type,
SUM(CASE WHEN account_id IN ('TAX','PAY') and
acct_open_dt BETWEEN TO_DATE('2006-01-17', 'yyyy-mm-dd') and
TO_DATE('2006-01-17', 'yyyy-mm-dd') + 60 THEN 1
ELSE 0 END) tax_pay,
SUM(CASE WHEN account_id NOT IN ('TAX','PAY') and
acct_open_dt BETWEEN TO_DATE('2006-01-17', 'yyyy-mm-dd') and
TO_DATE('2006-01-17', 'yyyy-mm-dd') + 30 THEN 1
ELSE 0 END) not_tax_pay
FROM NL_ACCT
WHERE ind = 'N' and
em_ind = 'N' and
acct_open_dt BETWEEN TO_DATE('2006-01-17', 'yyyy-mm-dd') and
TO_DATE('2006-01-17', 'yyyy-mm-dd') + 60
GROUP BY segment_name, product_type
ORDER BY product_typeNote: You cannor GROUP BY 1,2, you need to explicitly name the columns to group by.
HTH
John -
How can I use a READ statement for the checking date =sydatum?
Hello,
I need use a READ statement on an internal table ITAB (with feild var1) and check whether feild var1<= sydatum(i.e. var1 greater than or equal to sy-datum)....how can I implement this??
Regards,
Shashank.Hi,
try this short example.
DATA: BEGIN OF ITAB OCCURS 0,
DATE LIKE SY-DATUM,
END OF ITAB.
ITAB-DATE = '20000101'. APPEND ITAB.
ITAB-DATE = '20010101'. APPEND ITAB.
ITAB-DATE = '20020101'. APPEND ITAB.
ITAB-DATE = '20030101'. APPEND ITAB.
ITAB-DATE = '20040101'. APPEND ITAB.
ITAB-DATE = '20050101'. APPEND ITAB.
ITAB-DATE = '20060101'. APPEND ITAB.
ITAB-DATE = '20070101'. APPEND ITAB.
ITAB-DATE = SY-DATUM. APPEND ITAB.
ITAB-DATE = '20080101'. APPEND ITAB.
LOOP AT ITAB WHERE DATE < SY-DATUM.
WRITE: / 'before', ITAB-DATE.
ENDLOOP.
LOOP AT ITAB WHERE DATE = SY-DATUM.
WRITE: / 'equal ', ITAB-DATE.
ENDLOOP.
LOOP AT ITAB WHERE DATE > SY-DATUM.
WRITE: / 'after ', ITAB-DATE.
ENDLOOP.
Regards, Dieter -
How can I use an IF statement in the SELECT
Hi People,
I have a procedure called ENQUEUE_PROC which takes 3 parameters.
and I am trying to use an if statement in the select. I appreciate the help with this task.
here is my code.
Please have a look at my Select statement. What I have does not compile, however it might give you an idea of what i need.
PROCEDURE ENQUEUE_PROC(P_SUBMISSION_ID NUMBER,
P_EVENT VARCHAR2,
CASE_TYPE_CODE NUMBER;
) AS
XMLDATA XMLTYPE;
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message SYS.AQ$_JMS_TEXT_MESSAGE;
BEGIN
SELECT
XMLELEMENT("caseFileEvent", XMLATTRIBUTES('http://www.ussc.gov/soa/casefile/event/types' AS "xmlns",
'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns:ns0"),
XMLELEMENT("caseFileUploadEvent", XMLATTRIBUTES('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
'http://www.ussc.gov/soa/casefile/event/types ../xsd/Case_META.xsd' AS "xsi:schemaLocation",
'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns"),
XMLELEMENT("taskEvent", P_EVENT), --eg - 'SUBMIT', 'REJECT', 'RESUBMIT'
XMLELEMENT("defendentDetails",
XMLELEMENT("sentensingDate", SMD.SENT_VIO_DATE),
XMLELEMENT("personDetails",
// Here is where I want my IF statement, *********************************
IF CASE_TYPE_CODE = 10 THEN
XMLELEMENT("personNameDetails",
XMLELEMENT("firstName", SMD.FIRST_NAME),
XMLELEMENT("middleName", SMD.MIDDLE_NAME),
XMLELEMENT("lastName", SMD.LAST_NAME)
), -- personNameDetails
ELSE
XMLELEMENT("personNameDetails",
XMLELEMENT("corpname", SMD.CORPNAME),
), -- personNameDetails
XMLELEMENT("dateOfBirth", SMD.BIRTH_DATE)
) -- personDetails
), -- defendentDetails
XMLELEMENT("documentStatusDetails",
XMLELEMENT("otherStatus",
XMLELEMENT("intCode", NULL),
XMLELEMENT("description", NULL)
) -- otherStatus
), -- documentStatusDetails
XMLELEMENT("uploadOtherDetails",
XMLELEMENT("submissionId", SUB.SUBMISSION_ID),
XMLELEMENT("submissionSessionId", SUB.SUB_SESSION_ID),
XMLELEMENT("submissionMethod",
XMLELEMENT("intCode", SUB.SUB_MTHD_CODE),
XMLELEMENT("description", SM.DESCRIP)
), -- submissionMethod
XMLELEMENT("submissionReason",
XMLELEMENT("intCode", SUB.SUB_TYPE_CODE),
XMLELEMENT("description", SR.DESCRIP)
), -- submissionReason
XMLELEMENT("district",
XMLELEMENT("intCode", SMD.DIST_ID),
XMLELEMENT("description", D.DISTRICT_NAME)
), -- district
XMLELEMENT("caseFileType",
XMLELEMENT("intCode", SUB.CASE_TYPE_CODE),
XMLELEMENT("description", C.DESCRIP)
), -- caseFileType
XMLELEMENT("primaryDocketInfo",
XMLELEMENT("yearYY", SUBSTR(SMD.DOCKET, 1, 2)),
XMLELEMENT("id", SUBSTR(SMD.DOCKET, 3, 7)),
XMLELEMENT("defendentNumber", SMD.DEF_NUM)
), -- primaryDocketInfo
XMLELEMENT("PACTSId", SMD.PACTS_ID), -- PACTSId
XMLELEMENT("AOJudgeId",
XMLELEMENT("intCode", SMD.AO_JUDGE_ID),
XMLELEMENT("description", J.LAST_NAME || ', ' || J.FIRST_NAME || ', ' || J.MIDDLE_NAME)
), -- AOJudgeId
XMLELEMENT("missingCasefile", SUB.MISSING_CASE), -- missingCasefile
XMLELEMENT("creator",
XMLELEMENT("firstName", NULL),
XMLELEMENT("lastName", NULL),
XMLELEMENT("email", SUB.CREATOR_ID),
XMLELEMENT("actionDate", REGEXP_REPLACE( TO_CHAR(SUB.CREATE_TIME, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZR'), '...(......)$', '\1'))
), -- creator
XMLELEMENT("lastModifier",
XMLELEMENT("firstName", NULL),
XMLELEMENT("lastName", NULL),
XMLELEMENT("email", H.USER_ID),
XMLELEMENT("actionDate", TO_CHAR(H.ACTION_DATE, 'YYYY-MM-DD"T"HH24:MI:SS".000-05:00"'))
) -- lastModifier
) -- uploadOtherDetails
) -- caseFileUploadEvent
) -- caseFileEvent
INTO XMLDATA
FROM USSC_CASES.SUBMISSION SUB,
USSC_CASES.SUBMISSION_METADATA SMD,
USSC_CASES.CASE_HISTORY H,
LOOKUP.CASE_SUB_MTHD SM,
LOOKUP.CASE_SUB_TYPE SR,
LOOKUP.DISTRICTS D,
LOOKUP.JUDGES J,
LOOKUP.CASE_TYPES C
WHERE SUB.SUBMISSION_ID = SMD.SUBMISSION_ID
AND SUB.SUBMISSION_ID = H.SUBMISSION_ID
AND SUB.SUB_MTHD_CODE = SM.SUBMTHD_CODE
AND SUB.SUB_TYPE_CODE = SR.SUBTYPE_CODE
AND SUB.CASE_TYPE_CODE = C.CASE_TYPE_CODE
AND SMD.DIST_ID = D.USSC_DISTRICT_ID
AND SMD.AO_JUDGE_ID = J.AO_JUDGE_ID
AND H.ACTION_DATE IN (SELECT MAX(A.ACTION_DATE)
FROM USSC_CASES.CASE_HISTORY A
WHERE A.SUBMISSION_ID = P_SUBMISSION_ID)
AND SUB.SUBMISSION_ID = P_SUBMISSION_ID;
--dbms_output.put_line('queue start '|| xmldata.getclobval());
--insert into test1 values(xmldata);
message := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
message.set_text(xmldata.getStringVal());
DBMS_AQ.ENQUEUE(queue_name => 'case_file_queue', -- aqadm.cases_queue
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
COMMIT;
END ENQUEUE_PROC;thanks for the help,
I believe I almost got it to compilw, however I am getting Error(29,19): PL/SQL: ORA-00918: column ambiguously defined.
Of course CASE_TYPE_CODE is ambiguously because its passed in, is there a way around this.
Here is what i have so far.
PROCEDURE ENQUEUE_PROC(P_SUBMISSION_ID NUMBER,
P_EVENT VARCHAR2,
CASE_TYPE_CODE NUMBER // passed in field
) AS
XMLDATA XMLTYPE;
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message SYS.AQ$_JMS_TEXT_MESSAGE;
BEGIN
SELECT
XMLELEMENT("caseFileEvent", XMLATTRIBUTES('http://www.ussc.gov/soa/casefile/event/types' AS "xmlns",
'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns:ns0"),
XMLELEMENT("caseFileUploadEvent", XMLATTRIBUTES('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
'http://www.ussc.gov/soa/casefile/event/types ../xsd/Case_META.xsd' AS "xsi:schemaLocation",
'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns"),
XMLELEMENT("taskEvent", P_EVENT), --eg - 'SUBMIT', 'REJECT', 'RESUBMIT'
XMLELEMENT("defendentDetails",
XMLELEMENT("sentensingDate", SMD.SENT_VIO_DATE),
CASE
WHEN CASE_TYPE_CODE = 10 THEN
XMLELEMENT("personDetails",
XMLELEMENT("personNameDetails",
XMLELEMENT("firstName", SMD.FIRST_NAME),
XMLELEMENT("middleName", SMD.MIDDLE_NAME),
XMLELEMENT("lastName", SMD.LAST_NAME)
), -- personNameDetails
XMLELEMENT("dateOfBirth", SMD.BIRTH_DATE)
) -- personDetails
ELSE
XMLELEMENT("corporationDetails",
XMLELEMENT("organizationName", SMD.CORP_NAME)
) -- corporationDetails
END
), -- defendentDetails
XMLELEMENT("documentStatusDetails",
XMLELEMENT("otherStatus",
XMLELEMENT("intCode", NULL),
XMLELEMENT("description", NULL)
) -- otherStatus
), -- documentStatusDetails
XMLELEMENT("uploadOtherDetails",
XMLELEMENT("submissionId", SUB.SUBMISSION_ID),
XMLELEMENT("submissionSessionId", SUB.SUB_SESSION_ID),
XMLELEMENT("submissionMethod",
XMLELEMENT("intCode", SUB.SUB_MTHD_CODE),
XMLELEMENT("description", SM.DESCRIP)
), -- submissionMethod
XMLELEMENT("submissionReason",
XMLELEMENT("intCode", SUB.SUB_TYPE_CODE),
XMLELEMENT("description", SR.DESCRIP)
), -- submissionReason
XMLELEMENT("district",
XMLELEMENT("intCode", SMD.DIST_ID),
XMLELEMENT("description", D.DISTRICT_NAME)
), -- district
XMLELEMENT("caseFileType",
XMLELEMENT("intCode", SUB.CASE_TYPE_CODE),
XMLELEMENT("description", C.DESCRIP)
), -- caseFileType
XMLELEMENT("primaryDocketInfo",
XMLELEMENT("yearYY", SUBSTR(SMD.DOCKET, 1, 2)),
XMLELEMENT("id", SUBSTR(SMD.DOCKET, 3, 7)),
XMLELEMENT("defendentNumber", SMD.DEF_NUM)
), -- primaryDocketInfo
XMLELEMENT("PACTSId", SMD.PACTS_ID), -- PACTSId
XMLELEMENT("AOJudgeId",
XMLELEMENT("intCode", SMD.AO_JUDGE_ID),
XMLELEMENT("description", J.LAST_NAME || ', ' || J.FIRST_NAME || ', ' || J.MIDDLE_NAME)
), -- AOJudgeId
XMLELEMENT("missingCasefile", SUB.MISSING_CASE), -- missingCasefile
XMLELEMENT("creator",
XMLELEMENT("firstName", NULL),
XMLELEMENT("lastName", NULL),
XMLELEMENT("email", SUB.CREATOR_ID),
XMLELEMENT("actionDate", REGEXP_REPLACE( TO_CHAR(SUB.CREATE_TIME, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZR'), '...(......)$', '\1'))
), -- creator
XMLELEMENT("lastModifier",
XMLELEMENT("firstName", NULL),
XMLELEMENT("lastName", NULL),
XMLELEMENT("email", H.USER_ID),
XMLELEMENT("actionDate", TO_CHAR(H.ACTION_DATE, 'YYYY-MM-DD"T"HH24:MI:SS".000-05:00"'))
) -- lastModifier
) -- uploadOtherDetails
) -- caseFileUploadEvent
) -- caseFileEvent
INTO XMLDATA
FROM USSC_CASES.SUBMISSION SUB,
USSC_CASES.SUBMISSION_METADATA SMD,
USSC_CASES.CASE_HISTORY H,
LOOKUP.CASE_SUB_MTHD SM,
LOOKUP.CASE_SUB_TYPE SR,
LOOKUP.DISTRICTS D,
LOOKUP.JUDGES J,
LOOKUP.CASE_TYPES C
WHERE SUB.SUBMISSION_ID = SMD.SUBMISSION_ID
AND SUB.SUBMISSION_ID = H.SUBMISSION_ID
AND SUB.SUB_MTHD_CODE = SM.SUBMTHD_CODE
AND SUB.SUB_TYPE_CODE = SR.SUBTYPE_CODE
AND SUB.CASE_TYPE_CODE = C.CASE_TYPE_CODE
AND SMD.DIST_ID = D.USSC_DISTRICT_ID
AND SMD.AO_JUDGE_ID = J.AO_JUDGE_ID
AND H.ACTION_DATE IN (SELECT MAX(A.ACTION_DATE)
FROM USSC_CASES.CASE_HISTORY A
WHERE A.SUBMISSION_ID = P_SUBMISSION_ID)
AND SUB.SUBMISSION_ID = P_SUBMISSION_ID;
--dbms_output.put_line('queue start '|| xmldata.getclobval());
--insert into test1 values(xmldata);
message := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
message.set_text(xmldata.getStringVal());
DBMS_AQ.ENQUEUE(queue_name => 'case_file_queue', -- aqadm.cases_queue
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
COMMIT;
END ENQUEUE_PROC;Edited by: Rooney on Jan 31, 2012 1:55 PM -
How can I use control break statement in my requirement
Hi ABAPers,
In my requirement, I have 4 fields in sorted internal table, (audat, prdha, ipnum, netwr). In that i need to do summation of netwr field falling under same prdha(BU) for the same month
internal table fields :
audat prdha ipnum netwr
02 abc 1 100
02 abc 2 200
02 xyz 3 300
03 abc 4 100
03 xyz 5 300
03 xyz 6 200
i need output like this:
audat prdha ipnum netwr
02 abc 1,2 300
02 xyz 3 300
03 abc 4 100
03 xyz 5,6 500
Can anyone suggest me logic for this by using control break statements
Thanks in advance,
Ankita
Moderator Message: Duplciate Post.
Edited by: kishan P on Apr 14, 2011 3:03 PMHi ABAPers,
In my requirement, I have 4 fields in sorted internal table, (audat, prdha, ipnum, netwr). In that i need to do summation of netwr field falling under same prdha(BU) for the same month
internal table fields :
audat prdha ipnum netwr
02 abc 1 100
02 abc 2 200
02 xyz 3 300
03 abc 4 100
03 xyz 5 300
03 xyz 6 200
i need output like this:
audat prdha ipnum netwr
02 abc 1,2 300
02 xyz 3 300
03 abc 4 100
03 xyz 5,6 500
Can anyone suggest me logic for this by using control break statements
Thanks in advance,
Ankita
Moderator Message: Duplciate Post.
Edited by: kishan P on Apr 14, 2011 3:03 PM -
Using DB2's import/export utilities in Java program
DB2 database has build in utility called export, throgh which we can export the output of a Query directly onto a Lotus 123 file. But I beleive that , to invoke such DB2 utilities throgh a Java Program, we need to have APIs.
My question is ,are such APIs available ?
If so, what are the APIs necessary for calling this EXPORT and IMPORT utilities of DB2 ?Well, If you have to use Runtime.exec() and provide these as command lines, then the best option is to write a shell script( my Java application is on AIX platform) and then call the shell script through exec().
But Shell scripts don't run well with Runtime.exec() right ?
B'Cause, I tried it but the application did'nt throw up any exception. No message was flashed either. The process was just hanging.....so do you know a better method to actually run a shell script through a Java program ? -
How can I use UNIX "ls -lt" command in JAVA?
I have a piece of java code whose function is to search for all
the files in a directory and attach the time of the file creation.
How can I do it? Also, I know that in UNIX, "ls -lt" will give me
all the file names and the creation times. So how can I use "ls -lt"
in Java?O,I see you have notice my friend tsith,its not really about what language is better its about what language is better to start off with,this is the twist and the diffrents to other postings and so far I have not seen a good argument saying y java is a better language to start off with.Anyways the ? still stands is java a better language to start off with then c/c++???.If you ask me c/c++ is better and I am just waiting for a good argument to give my reasons.Anysways good to see you are still around tsith ;-).
-
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? -
How to compile and execute lex,yac,c and java programs
its the 3rd day on my New MacBook pro..
as i just migrated from windows to mac i love to work on this..
The main problem is i DON't know .......
how to compile and execute
1) lex and yac programs
2) c program
3) java program
so please help me
THIS is the error i got a1.l is a program
i got the same error when i used gcc
$ lex a1.l
$ cc lex.yy.c
Undefined symbols:
"_yywrap", referenced from:
_yylex in cc8QDQjW.o
_input in cc8QDQjW.o
ld: symbol(s) not found
collect2: ld returned 1 exit statusIs the problem that you don't know how to compile and execute these programs on a Mac, or just that you don't know how to compile and execute them?
Mac OS X is really just a version of BSD Unix, as far as programs like like bison, flex and gcc are concerned...and even when Apple specific versions are provided in the Developer Tools, there are symlinks in the usual places in the Unix file hierarchy.
For problems with lex and yacc, I suggest you start with their own references, for example, here.
Or you could just use %option noyywrap, if you only have one file to scan.
Or you could link to libfl.a using -lfl and use the default version from that library.
But you really should (as Keith Barkley was subtly hinting at) learn how these tools work and why they work that way.
Maybe you are looking for
-
SharePoint 2013 SSRS in SharePoint Mode - Reports not loading controls.
Hello All, I have recently run across an issue that has stumped me and my DBA. We have just walked through installing SSRS 2012 w/SP1 in SharePoint (SharePoint 2013) mode according to these instructions here. Everything went just fine during the inst
-
All of a sudden when I try to import video from my camera to iMovie it won't work. The first thing that happens in the automatic mode is that it shuts off and says stopped. Then I switch to manual and the whole video imports but the screen is blue
-
Multiple "Sites" in One Remote Folder
I am a student of Digital Design. I have created my first website but now it is time to put my second project out on the web. I want to be able to access both the old and new sites. How do I do this? Thank you.
-
Droid 2 - Location of Sound and Video Files
Trying to move images, sounds, videos from an old phone(LG Touch) to a new Droid 2. I got all the files off the LG and found the DCIM folder on the Droid after connecting USB cable to computer. Where are video and sound files saved on the Droid? Are
-
Boot screen resolution does not match the login screen on retina
Boot screen resolution does not match the login screen on MBP retinas if you've set your resolution to hi-res thus resulting a flickering at login screen appearing instead of that nice login screen animation, due to I believe screen resolution change