Creating a Java Database(derby) using DBFactory
Hi
I want to create a Java Database (derby) when running Main. My main program is parsing driver, url, user id and user password to the DBFactory class. I am using netbeans 5.5 with the Sun Java System Application Server and the Java DB server is up and running.
When I run the main program I get no output and no errors. If you will take a look at the main class below and check for novice errors it would much appreciated.
public class Main {
private String driver = "org.apache.derby.jdbc.ClientDriver";
private String url = "jdbc:derby://localhost:1527/";
private String uid = "user";
private String pwd = "user";
private Connection con;
public Main() {
try {
DBFactory db = new DBFactory(driver, url + "JavaDBTest", uid, pwd);
con = db.getConnection();
HashMap metaData = getMetaData();
Iterator meta = metaData.entrySet().iterator();
while (meta.hasNext()) {
Map.Entry entry = (Map.Entry) meta.next();
System.out.println(
(String)entry.getKey() + ": " + (String)entry.getValue());
db.createDB("JavaDBTest");
Statement st = con.createStatement();
ResultSet res = st.executeQuery("show tables");
while (res.next()) {
System.out.println(res.getString(1));
st.executeUpdate("insert into JavaDBTest(name,phone) " +
"values('donald duck', '12345678')");
st.executeUpdate("insert into JavaDBTest(name,phone) " +
"values('mickey mouse', '87654321')");
res = st.executeQuery("select * from JavaDBTest");
while (res.next()) {
System.out.println(
res.getString("name") + " " + res.getString("phone"));
int i = st.executeUpdate("delete from JavaDBTest");
System.out.println("Rows deleted: " + i);
db.dropDB("JavaDBTest");
catch (ClassNotFoundException cnfe) {
System.err.println(cnfe.getMessage());
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
add the main entry method to your progam :
public class Main {
private String driver = "org.apache.derby.jdbc.ClientDriver";
private String url = "jdbc:derby://localhost:1527/";
private String uid = "user";
private String pwd = "user";
private Connection con;
public Main() {
try {
DBFactory db = new DBFactory(driver, url + "JavaDBTest", uid, pwd);
con = db.getConnection();
HashMap metaData = getMetaData();
Iterator meta = metaData.entrySet().iterator();
while (meta.hasNext()) {
Map.Entry entry = (Map.Entry) meta.next();
System.out.println(
(String)entry.getKey() + ": " + (String)entry.getValue());
db.createDB("JavaDBTest");
Statement st = con.createStatement();
ResultSet res = st.executeQuery("show tables");
while (res.next()) {
System.out.println(res.getString(1));
st.executeUpdate("insert into JavaDBTest(name,phone) " +
"values('donald duck', '12345678')");
st.executeUpdate("insert into JavaDBTest(name,phone) " +
"values('mickey mouse', '87654321')");
res = st.executeQuery("select * from JavaDBTest");
while (res.next()) {
System.out.println(
res.getString("name") + " " + res.getString("phone"));
int i = st.executeUpdate("delete from JavaDBTest");
System.out.println("Rows deleted: " + i);
db.dropDB("JavaDBTest");
catch (ClassNotFoundException cnfe) {
System.err.println(cnfe.getMessage());
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
public static void main(String[] args) {
new Main();
}then run your program again and post the errors message.
hth
Similar Messages
-
How to create a new database and use it?
Hi there,
I have so many tables in the current database that i'm working on. When i start to create a new table such as employee, student, person...etc it doesnt allow me to create them becuase it says the tables exists. Even when i use the drop command to drop the tables, doesn't help. So most of the time i have to create a table with postfix of 1, 2 to the table name.
Therefore i need to create a database for every project that i do.
How do i create a new database?
Then how do i use the database that i just created?
Then how do i find the out whats the database that i'm currently working on?
Thanks!
Message was edited by:
dingdong
Message was edited by:
dingdongA database is a physical set of files that contains many schemas. Each schema has a one to one relationship with database users, so to create a new schema you create a new database user.
e.g.
CREATE USER fred IDENTIFIED BY fredspassword;Then, by logging on as fred you can create all the new tables you like as that user, in that users schema.
If you create a new database then you will find you cannot access functions/procedures, packages, tables etc. that exist in another users schema without creating a database link to the other database that contains them.
If you just create a new schema, you can more easily get at other users schema objects (tables, packages etc.) by referencing them with the users name e.g. JOE.TABLE1 providing that user has given permission for your user to access them. You can also create synonyms that allow you to reference other users schema objects as if they exist in your own e.g. you can have something called TABLE1 in your own schema that is in fact referencing JOE.TABLE1.
Message was edited by:
BluShadow
remove quotes from password. oops! thanks padders -
How to create logical standby database without using Oracle Grid Control
Hi All,
I want to create Logical standby database on 11gr2 on RHEL 5 without using oracle Grid Control.
I already have a primary database as well as physical standby database.
What i want to create a logical standby database as well on the same machine where physical standby database is running.
So anyone of you help me out to do that
Thanks in advanceHi,
Creating a Logical Standby Database
http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/create_ls.htm#SBYDB00300
Regards,
Tom -
Creating a java Web Service Using Axis
I need to write a Java web Service using Axis which send a file as an DIme attachement and It should to be invoked by .NET Client .
I need to know how to attach a file to Soap response and how to read a file from the response at Client.
I am new to web Services ,,please help me......Hi
You can use a java web service to publish a Web service from a Java class.
A wizard creates the WSDL document and deployment files needed to publish your code as a Web service. After you select the class and methods you want to publish, the wizard generates deployment descriptors, a JAX-RPC mapping file, and a WSDL document that can be deployed to an application server.
You can refer : \bpel\samples\tutorials\102.InvokingProcesses\ws sample to invoke a WS using JAX-RPC Call.
Hope that helps!
Cheers
A -
Tool to create Java Object classes using the Database Tables
Hi,
Is their any tools or utility available to create the Java Object Classes using the Database Tables as input.
Lets Say I am having the Employee, Employee_Salary tables in the Database.The utility has to create the Java Object classes with the relation.
Please Help...
Thx..Hm, for generating regular Java classes I wouldn't know one from memory. But I suggest you start searching in for example the Eclipse marketspace for a third party plugin that can do it. If all fail, you could always use Hibernate Tools from the Jboss Tools Eclipse plugin set to generate Hibernate/JPA entities and then strip the annotations from them to turn them into regular POJO classes.
How many tables are we talking about anyway? It might be less effort to just create the classes with properties and then use an IDE to generate getters and setters for them. -
How to create Java client to use WCC web services
I'm trying to create a Java client to use web services available with Web Center Content.
I generated stubs using "cxf-codegen-plugin" and I wrote following code (very trivial):
DocInfo docInfo = null;
*try {*
docInfo = new DocInfo(new URL("http://vmxp43:16200/cs/idcplg?IdcService=GET_SOAP_WSDL_FILE&wsdlName=DocInfo&idcToken=1344065729220:B443F7C3DED844B594F32E0B3914E576&IsSoap=1"));
*} catch (MalformedURLException e) {*
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
DocInfoSoap docInfoSoap = docInfo.getDocInfoSoap();
DocInfoByIDResult docInfoByIDResult = docInfoSoap.docInfoByID(new Integer(2), null);
At the moment I'm obtaining following error:
Exception in thread "main" javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://vmxp43:16200/cs/idcplg?IdcService=GET_SOAP_WSDL_FILE&wsdlName=DocInfo&idcToken=1344065729220:B443F7C3DED844B594F32E0B3914E576&IsSoap=1. It failed with:
* Invalid WSDL http://vmxp43:16200/cs/idcplg?IdcService=GET_SOAP_WSDL_FILE&wsdlName=DocInfo&idcToken=1344065729220:B443F7C3DED844B594F32E0B3914E576&IsSoap=1, expected {http://schemas.xmlsoap.org/wsdl/}definitions found html at (lineLine number = 3*
Column number = 30
System Id = http://vmxp43:16200/cs/idcplg?IdcService=GET_SOAP_WSDL_FILE&wsdlName=DocInfo&idcToken=1344065729220:B443F7C3DED844B594F32E0B3914E576&IsSoap=1
Public Id = null
Location Uri= http://vmxp43:16200/cs/idcplg?IdcService=GET_SOAP_WSDL_FILE&wsdlName=DocInfo&idcToken=1344065729220:B443F7C3DED844B594F32E0B3914E576&IsSoap=1
CharacterOffset = 133
* at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:151)*
* at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:127)*
* at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254)*
* at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:217)*
* at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:165)*
* at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93)*
* at javax.xml.ws.Service.<init>(Service.java:56)*
* at com.stellent.docinfo.DocInfo.<init>(DocInfo.java:39)*
* at eu.europa.efsa.virtual.library.services.client.TestDocInfo.main(TestDocInfo.java:23)*
*Caused by: javax.xml.stream.XMLStreamException: Invalid WSDL http://vmxp43:16200/cs/idcplg?IdcService=GET_SOAP_WSDL_FILE&wsdlName=DocInfo&idcToken=1344065729220:B443F7C3DED844B594F32E0B3914E576&IsSoap=1, expected {http://schemas.xmlsoap.org/wsdl/}definitions found html at (lineLine number = 3*
Column number = 30
System Id = http://vmxp43:16200/cs/idcplg?IdcService=GET_SOAP_WSDL_FILE&wsdlName=DocInfo&idcToken=1344065729220:B443F7C3DED844B594F32E0B3914E576&IsSoap=1
Public Id = null
Location Uri= http://vmxp43:16200/cs/idcplg?IdcService=GET_SOAP_WSDL_FILE&wsdlName=DocInfo&idcToken=1344065729220:B443F7C3DED844B594F32E0B3914E576&IsSoap=1
CharacterOffset = 133
* at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:120)*
* ... 7 more*
Please, any comment will be appreciated.Now I'm trying following code.
DocInfo docInfo = new DocInfo();
DocInfoSoap docInfoSoap = docInfo.getDocInfoSoap();
DocInfoByIDResult docInfoByIDResult = docInfoSoap.docInfoByID(new Integer(2), null);
The error I obtain is:
Exception in thread "main" com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 401: Unauthorized
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.checkStatusCode(HttpTransportPipe.java:196)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:168)
at com.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:83)
at com.sun.xml.internal.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:105)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Fiber.java:587)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Fiber.java:546)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Fiber.java:531)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Fiber.java:428)
at com.sun.xml.internal.ws.client.Stub.process(Stub.java:211)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(SEIStub.java:124)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:98)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at $Proxy28.docInfoByID(Unknown Source)
at eu.europa.efsa.virtual.library.services.client.TestDocInfo.main(TestDocInfo.java:20)
Is there a way to pass right username and password?
How can I understand which the user actually used? -
Java DataBase in NetBeans!!
Hi there,
can you help guy,
I have the NetBeans IDE 4.1,
Oracle 9,
j2sdk1.4.0,
and win xp (on standalone machine)
I remember the old version of NetBeans, you can use Mounting FileSystem for jdbc\oracle\driver
to use the OracleDriver
but I get message error at compiler says that package jdbc.oracle.driver does not exist
please I need help in who to do Mounting FileSystem or other way
here is my code of java
// Database application using Oracle and Java programming Language
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import jdbc.sql.*
import java.awt.*;
public class OracleJavaCustomerWindow extends JFrame
private JLabel labelCId,labelCName,labelCCity,labelCPhone;
private JTextField textCId,textCName,textCCity,textCPhone;
private JPanel labelPanel,buttonPanel,textAreaPanel,labelTextAreaPanel;
private JTextArea outputArea;
private JScrollPane scrollPane;
private JButton buttonDisplay,buttonAdd,buttonModifyRecord,buttonUpdate,buttonDelete;
private JButton buttonClear;
private JTextField field1,field2,field3,field4;
private JLabel label1,label2,label3,label4;
private JPanel mixedPanel,mixedPanel2,fieldPanel1,fieldPanel2,fieldPanel3,fieldPanel4;
static Connection sqlconn = null;
// set up GUI with constrictor(IT IS A METHOD. EACHO CLASS AT LEST HAVE ONE)
public OracleJavaCustomerWindow ()
super("Display Oracle Data for Customers");
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
sqlconn= DriverManager.getConnection ("jdbc:oracle:oci:@Kawasaki", "scott", "tiger");
catch(SQLException ex)
System.out.println("SQLException:" + ex.getMessage() + "<BR>");
// add GUI components to container
Container container = getContentPane();
container.setLayout(new FlowLayout(FlowLayout.CENTER));
// Build labelPanel
labelCId = new JLabel(" Customer ID");
labelCName = new JLabel("Customer Name");
labelCCity = new JLabel("Customer City");
labelCPhone = new JLabel("Customer Phone");
labelPanel = new JPanel();
labelPanel.setLayout(new FlowLayout(FlowLayout.CENTER,3,5));
labelPanel.add(labelCId);
labelPanel.add(labelCName);
labelPanel.add(labelCCity);
labelPanel.add(labelCPhone);
// Build textAreaPanel
outputArea = new JTextArea(10,30);
outputArea.setEditable(false);
scrollPane = new JScrollPane(outputArea);
textAreaPanel = new JPanel();
textAreaPanel.setLayout(new FlowLayout(FlowLayout.CENTER,3,5));
textAreaPanel.add(scrollPane);
// Build labelTextAreaPanel which contains labelPanel and textAreaPanel
// to be ready for adding to container
labelTextAreaPanel= new JPanel();
labelTextAreaPanel.setLayout(new BorderLayout());
labelTextAreaPanel.add(labelPanel,BorderLayout.NORTH);
labelTextAreaPanel.add(textAreaPanel,BorderLayout.SOUTH);
// Buld buttonPanel
buttonDisplay = new JButton ("Display Table");
buttonClear = new JButton ("Clear");
buttonAdd = new JButton("Add New Record");
buttonUpdate= new JButton("Display Record");
buttonModifyRecord = new JButton("Modify Record");
buttonDelete = new JButton("Delete Record");
buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(6,1,10,5));
buttonPanel.add(buttonAdd);
buttonPanel.add(buttonUpdate);
buttonPanel.add(buttonModifyRecord);
buttonPanel.add(buttonDisplay);
buttonPanel.add(buttonDelete);
buttonPanel.add(buttonClear);
// build fieldPanel1
label1 = new JLabel("Customer Number");
field1 = new JTextField(10);
fieldPanel1 = new JPanel();
fieldPanel1.setLayout(new FlowLayout(FlowLayout.CENTER,3,5));
fieldPanel1.add(label1);
fieldPanel1.add(field1);
// build fieldPanel2
fieldPanel2 = new JPanel();
label2 = new JLabel("Customer Name");
field2 = new JTextField(10);
fieldPanel2.setLayout(new FlowLayout(FlowLayout.CENTER,3,5));
fieldPanel2.add(label2);
fieldPanel2.add(field2);
// build fieldPanel3
fieldPanel3 = new JPanel();
label3 = new JLabel("Customer City");
field3 = new JTextField(10);
fieldPanel3.setLayout(new FlowLayout(FlowLayout.CENTER,3,5));
fieldPanel3.add(label3);
fieldPanel3.add(field3);
// build fieldPanel4
fieldPanel4 = new JPanel();
label4 = new JLabel("Customer Phone");
field4 = new JTextField(10);
fieldPanel4.setLayout(new FlowLayout(FlowLayout.CENTER,3,5));
fieldPanel4.add(label4);
fieldPanel4.add(field4);
// Build mixedPanel which contains fieldPanel1, fieldPanel2,fieldPanel3
// to be ready for adding to container
mixedPanel = new JPanel();
mixedPanel.setLayout(new BorderLayout());
mixedPanel.add(fieldPanel1,BorderLayout.NORTH);
mixedPanel.add(fieldPanel2,BorderLayout.CENTER);
mixedPanel.add(fieldPanel3,BorderLayout.SOUTH);
mixedPanel2 = new JPanel();
mixedPanel2.add(fieldPanel4,BorderLayout.SOUTH);
// add all panels to the container
container.add(mixedPanel);
container.add(mixedPanel2);
container.setBackground(Color.DARK_GRAY);
container.add(labelTextAreaPanel);
container.add(buttonPanel);
//--------- Messages to communicate with different objects
//----------- method to clear the outputarea
buttonClear.addActionListener(
// anonymous inner class
new ActionListener()
public void actionPerformed(ActionEvent event)
outputArea.setText("");
}// actionPerformed
}// anonymous inner class
//--------- method to use button event--------------------
buttonDisplay.addActionListener(
//anonymous class
new ActionListener()
public void actionPerformed(ActionEvent event)
//Connection sqlca = null;
Statement sqlStatement = null;
ResultSet rset = null;
try{
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//sqlca= DriverManager.getConnection ("jdbc:oracle:thin:@dbserver:1521:infs", "manzur", "manzur");
sqlStatement = sqlconn.createStatement ();
rset = sqlStatement.executeQuery ("select * from customers");
while (rset.next ()){
String CUSTOMERID=rset.getObject(1).toString();
String CUSTOMERNAME =rset.getObject(2).toString();
String CUSTOMERCITY =rset.getObject(3).toString();
String CUSTOMERPHONE =rset.getObject(4).toString();
//String map=rset.getObject(4).toString();
//String region=rset.getObject(5).toString();
//System.out.println (id + "\t" + name + "\t" + loc );
outputArea.append(CUSTOMERID + "\t" + CUSTOMERNAME + "\t" + CUSTOMERCITY + "\t" + CUSTOMERPHONE + "\n" );
} // end while
}// end try
catch (SQLException ex)
System.out.println("SQLException:" + ex.getMessage() + "<BR>");
}// catch
}// action performed
} // anonymous inner class
);// end addActionListener
// ------ method to add Customers to the database
buttonAdd.addActionListener(
// anonymous inner class
new ActionListener()
public void actionPerformed(ActionEvent event)
try{
Statement sqlStatement = null;
ResultSet rtbookset = null;
// create statement
sqlStatement = sqlconn.createStatement();
int CUSTOMERID = Integer.parseInt(field1.getText());
String CUSTOMERNAME = field2.getText();
String CUSTOMERCITY = field3.getText();
int CUSTOMERPHONE = Integer.parseInt(field4.getText());
// create query
String insertquery = "INSERT INTO CUSTOMERS VALUES("
+ CUSTOMERID + "," + "'" + CUSTOMERNAME + "'," + "'" + CUSTOMERCITY + "'," + CUSTOMERPHONE + ")";
// execute the query
sqlStatement.executeQuery(insertquery);
// clear the textfields
field1.setText("");
field2.setText("");
field3.setText("");
field4.setText("");
JOptionPane.showMessageDialog(null,"Record added");
}// try
catch(SQLException ex)
System.out.println("Record exists :" + ex.getMessage() + "<BR>");
}// catch
}// actionPerformed
}// anonymous inner class
//--------- method to use buttonUpdate event--------------------
buttonUpdate.addActionListener(
//anonymous class
new ActionListener()
public void actionPerformed(ActionEvent event)
//Connection sqlconn = null;
Statement sqlStatement = null;
ResultSet rset = null;
int CUSTOMER_ID = Integer.parseInt(field1.getText());
try{
//int CUSTOMER_ID = Integer.parseInt(field1.getText());
//String d_name = field2.getText();
//String d_loc = field3.getText();
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//sqlca= DriverManager.getConnection ("jdbc:oracle:thin:@dbserver:1521:infs", "manzur", "manzur");
sqlStatement = sqlconn.createStatement ();
rset = sqlStatement.executeQuery ("select * from CUSTOMERS where CUSTOMER_ID =" + CUSTOMER_ID);
rset.next ();
//int id=rset.getInt("DEPTNO");
String CUSTOMERID = rset.getObject(1).toString();
String CUSTOMERNAME=rset.getString("CUSTOMER_NAME");
String CUSTOMERCITY=rset.getString("CUSTOMER_CITY");
String CUSTOMERPHONE=rset.getString("CUSTOMER_PHONE");
field1.setText(CUSTOMERID);
field2.setText(CUSTOMERNAME);
field3.setText(CUSTOMERCITY);
field4.setText(CUSTOMERPHONE);
//buttonUpdate.setEnabled(false);
//buttonModifyRecord.setEnabled(true);
//rset.close();
}// end try
catch (SQLException ex)
JOptionPane.showMessageDialog(null,"No Record found with CUSTOMER ID :" + CUSTOMER_ID );
//System.out.println("SQLException:No record found" + ex.getMessage() + "<BR>");
}// catch
}// action performed
} // anonymous inner class
);// end addActionListener
//---------Method to modify record------------------------------------
buttonModifyRecord.addActionListener(
//anonymous class
new ActionListener()
public void actionPerformed(ActionEvent event)
//Connection sqlconn = null;
Statement sqlStatement = null;
ResultSet rset = null;
try{
//int dept_no = Integer.parseInt(field1.getText());
//String d_name = field2.getText();
//String d_loc = field3.getText();
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//sqlca= DriverManager.getConnection ("jdbc:oracle:thin:@dbserver:1521:infs", "manzur", "manzur");
sqlStatement = sqlconn.createStatement ();
int CUSTOMERID = Integer.parseInt(field1.getText());
String CUSTOMERNAME = field2.getText();
String CUSTOMERCITY = field3.getText();
int CUSTOMERPHONE = Integer.parseInt(field4.getText());
String updatequery = "UPDATE CUSTOMERS SET CUSTOMER_NAME = " + "'" + CUSTOMERNAME + "',"
+ " CUSTOMER_CITY = " + "'" + CUSTOMERCITY + "'," + " CUSTOMER_PHONE = " + CUSTOMERPHONE
+ " Where CUSTOMER_ID = " + CUSTOMERID;
// execute the query
sqlStatement.executeQuery(updatequery);
// clear the textfields
field1.setText("");
field2.setText("");
field3.setText("");
field4.setText("");
JOptionPane.showMessageDialog(null,"Record modified");
//buttonUpdate.setEnabled(true);
//buttonModifyRecord.setEnabled(false);
}// end try
catch (SQLException ex)
System.out.println("SQLException:" + ex.getMessage() + "<BR>");
}// catch
}// action performed
} // anonymous inner class
);// end addActionListener
//---------Method to modify record------------------------------------
buttonDelete.addActionListener(
//anonymous class
new ActionListener()
public void actionPerformed(ActionEvent event)
//Connection sqlca = null;
Statement sqlStatement = null;
ResultSet rset = null;
try{
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
//sqlca= DriverManager.getConnection ("jdbc:oracle:thin:@dbserver:1521:infs", "manzur", "manzur");
sqlStatement = sqlconn.createStatement ();
int CUSTOMERID = Integer.parseInt(field1.getText());
//String d_name = field2.getText();
//String d_loc = field3.getText();
String deletequery = "DELETE from CUSTOMERS "
+ " Where CUSTOMER_ID = " + CUSTOMERID;
// execute the query
sqlStatement.executeQuery(deletequery);
// clear the textfields
field1.setText("");
field2.setText("");
field3.setText("");
field4.setText("");
JOptionPane.showMessageDialog(null,"Record Deleted");
//buttonUpdate.setEnabled(true);
//buttonModifyRecord.setEnabled(false);
}// end try
catch (SQLException ex)
System.out.println("SQLException:" + ex.getMessage() + "<BR>");
}// catch
}// action performed
} // anonymous inner class
);// end addActionListener
// specify the size of the window
setSize(800,500);
show();
}// constructor
public static void main(String args[]) throws IOException{
OracleJavaCustomerWindow application = new OracleJavaCustomerWindow();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}// main
} // class OracleJavaWindow
// exceptions classes
// inserFailedException is a general exception for
// SQL insert problems
/*class insertFailedException extends SQLException
public insertFailedException(String reason)
super(reason);
public insertFailedException(String reason)
super();
}*/Sorry guys here is the correction of details i have provided
the Error message tells me that
package oracle.jdbc.driver does not exist
and the folder I used to do Mounting SystemFile for was
C:\Oracle\jdbc\lib\classes12 -
Problem in Creating a new database in Oracle 9i
I have installed Oracle 9i for Windows successfully. Now when I try to create a new database either using the Database Configuration Assistant or using the script generated by the Assistant, I get an error message that DATABASE NOT OPEN. So the database will not be created. Please help in this regard, so that I can create a database and I can start working on Oracle 9i.
Thanks in advance.
KiranHi DENIS,
I have executed the following commands (which are in a script file),
1. sqlplus /nolog
2. connect sys/change_on_install as sysdba
3. create database ...
4. ...
When I execute the 3rd command, I get an error message as "ORACLE TERMINATED FORCED" and it will end the session. So when the next set of commands in the script are executed, I got the error saying "DATABASE NOT OPEN".
How to rectify this problem.
Thanks in advance,
Kiran -
Creating a test database from backups of the production
Hello Experts,
I am a newbie with very much new in Oracle. I have been provided with the inc0 backup(which comprises even the controlfile backup) of the production database (PROD) taken through RMAN and asked to create a new test database (TEST) using the backup. Can anyone please provide me the steps on how to restore it and create the new database ?
Database version 10.2.0.4
I am aware of duplicate database concept using RMAN, but I have been asked to not to connect to the target (PROD) database while duplicating. So, I need to create the test database by using the backup of prod database without connecting to PROD database. Please guide me.Refer
http://arjudba.blogspot.in/2008/05/restore-and-recover-database-to-new.html
RMAN restore database from another backup of different database name
When you are restoring using the backup of the production database, the db_name would be same on the auxiliary database. Once you restore and recover the database in your test server, you can change the db_name from prod to test by recreating the controlfile -
Create solution in database getting error in service desk
Dear All,
Creating solution in database in using tcode :-crm_dno_monitor i m grtting following error .
Note
The following error text was processed in the system FCS : The ABAP/4 Open SQL array insert results in duplicate database records. records in the data base.
The error occurred on the application server solman_FCS_00 and in the work process 0 .
The termination type was: RABAX_STATE
The ABAP call stack was:
Function: ISMV_POST_SYMP of program SAPLISMV
Function: ISMV_GENERATE_SYMPTOM of program SAPLISMV
Form: GENERATE_SYMPTOM of program SAPLISMB
Form: POST_SYMPTOM of program SAPLISMB
Form: %_PROCESS_P_O_C of program SAPMSSY0
Form: %_COMMIT of program SAPMSSY0
Method: CREATE_SDB_SYM_SOL of program CL_SDK_SDB_NOTIFICATION=======CP
Method: SAVE_WORK of program /1BCWDY/87Q4WT7CHMIIT1OWR9O3==CP
Method: IF_COMPONENTCONTROLLER~SAVE_WORK of program /1BCWDY/87Q4WT7CHMIIT1OWR9O3==CP
Method: ONACTIONBTN_SAVE of program /1BCWDY/87Q4WT7CHMIIT1OWR9O3==CP
I check the trace log w0 log its giving this error.
ABAP Program SAPLISMV .
Source LISMVU01 Line 13.
Error Code SAPSQL_ARRAY_INSERT_DUPREC.
Module $Id: //bas/700_REL/src/krn/runt/absapsql.c#11 $ SAP.
Function HandleRsqlErrors Line 782.
RABAX: level LEV_RX_STDERR completed.
RABAX: level LEV_RX_RFC_ERROR entered.
RABAX: level LEV_RX_RFC_ERROR completed.
RABAX: level LEV_RX_RFC_CLOSE entered.
RABAX: level LEV_RX_RFC_CLOSE completed.
RABAX: level LEV_RX_IMC_ERROR entered.
RABAX: level LEV_RX_IMC_ERROR completed.
RABAX: level LEV_RX_DATASET_CLOSE entered.
RABAX: level LEV_RX_DATASET_CLOSE completed.
RABAX: level LEV_RX_RESET_SHMLOCKS entered.
RABAX: level LEV_RX_RESET_SHMLOCKS completed.
RABAX: level LEV_RX_ERROR_SAVE entered.
RABAX: level LEV_RX_ERROR_SAVE completed.
RABAX: level LEV_RX_ERROR_TPDA entered.
RABAX: level LEV_RX_ERROR_TPDA completed.
RABAX: level LEV_RX_PXA_RELEASE_RUDI entered.
RABAX: level LEV_RX_PXA_RELEASE_RUDI completed.
RABAX: level LEV_RX_LIVE_CACHE_CLEANUP entered.
RABAX: level LEV_RX_LIVE_CACHE_CLEANUP completed.
RABAX: level LEV_RX_END entered.
RABAX: level LEV_RX_END completed.
Regards
AshokDear Ashok,
Kindly please review the following notes :
1124452 - Dump in ISMV_POST_SYMP during problem/solution-creation
1002299 - Missing Customizing data in SAF, Part II
They should help resolve the issue.
Regards
Amit -
How to create a report with data using the Crystal Reports for Java SDK
Hi,
How do I create a report with data that can be displayed via the Crystal Report for Java SDK and the Viewers API?
I am writing my own report designer, and would like to use the Crystal Runtime Engine to display my report in DHTML, PDF, and Excel formats. I can create my own report through the following code snippet:
ReportClientDocument boReportClientDocument = new ReportClientDocument();
boReportClientDocument.newDocument();
However, I cannot find a way to add data elements to the report without specifying an RPT file. Is this possible? I seems like it is since the Eclipse Plug In allows you to specify your database parameters when creating an RPT file.
is there a way to do this through these packages?
com.crystaldecisions.sdk.occa.report.data
com.crystaldecisions.sdk.occa.report.definition
Am I forced to create a RPT file for the different table and column structures I have?
Thank you in advance for any insights.
Ted JenneyHi Rameez,
After working through the example code some more, and doing some more research, I remain unable to populate a report with my own data and view the report in a browser. I realize this is a long post, but there are multiple errors I am receiving, and these are the seemingly essential ones that I am hitting.
Modeling the Sample code from Create_Report_From_Scratch.zip to add a database table, using the following code:
<%@ page import="com.crystaldecisions.sdk.occa.report.application.*"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.data.*"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.document.*"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.definition.*"%>
<%@ page import="com.crystaldecisions.sdk.occa.report.lib.*" %>
<%@ page import = "com.crystaldecisions.report.web.viewer.*"%>
<%
try {
ReportClientDocument rcd = new ReportClientDocument();
rcd.newDocument();
// Setup the DB connection
String database_dll = "Sqlsrv32.dll";
String db = "qa_start_2012";
String dsn = "SQL Server";
String userName = "sa";
String pwd = "sa";
// Create the DB connection
ConnectionInfo oConnectionInfo = new ConnectionInfo();
PropertyBag oPropertyBag1 = oConnectionInfo.getAttributes();
// Set new table logon properties
PropertyBag oPropertyBag2 = new PropertyBag();
oPropertyBag2.put("DSN", dsn);
oPropertyBag2.put("Data Source", db);
// Set the connection info objects members
// 1. Pass the Logon Properties to the main PropertyBag
// 2. Set the Server Description to the new **System DSN**
oPropertyBag1.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES, oPropertyBag2);
oPropertyBag1.put(PropertyBagHelper.CONNINFO_CRQE_SERVERDESCRIPTION, dsn);
oPropertyBag1.put("Database DLL", database_dll);
oConnectionInfo.setAttributes(oPropertyBag1);
oConnectionInfo.setUserName(userName);
oConnectionInfo.setPassword(pwd);
// The Kind of connectionInfos is CRQE (Crystal Reports Query Engine).
oConnectionInfo.setKind(ConnectionInfoKind.CRQE);
// Add a Database table
String tableName = "Building";
Table oTable = new Table();
oTable.setName(tableName);
oTable.setConnectionInfo(oConnectionInfo);
rcd.getDatabaseController().addTable(oTable, null);
catch(ReportSDKException RsdkEx) {
out.println(RsdkEx);
catch (Exception ex) {
out.println(ex);
%>
Throws the exception
com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: java.lang.NullPointerException---- Error code:-2147467259 Error code name:failed
There was other sample code on SDN which suggested the following - adding the table after calling table.setDataFields() as in:
String tableName = "Building";
String fieldname = "Building_Name";
Table oTable = new Table();
oTable.setName(tableName);
oTable.setAlias(tableName);
oTable.setQualifiedName(tableName);
oTable.setDescription(tableName) ;
Fields fields = new Fields();
DBField field = new DBField();
field.setDescription(fieldname);
field.setHeadingText(fieldname);
field.setName(fieldname);
field.setType(FieldValueType.stringField);
field.setLength(40);
fields.add(field);
oTable.setDataFields(fields);
oTable.setConnectionInfo(oConnectionInfo);
rcd.getDatabaseController().addTable(oTable, null);
This code succeeds, but it is not clear how to add that database field to a section. If I attempt to call the following:
FieldObject oFieldObject = new FieldObject();
oFieldObject.setDataSourceName(field.getFormulaForm());
oFieldObject.setFieldValueType(field.getType());
// Now add it to the section
oFieldObject.setLeft(3120);
oFieldObject.setTop(120);
oFieldObject.setWidth(1911);
oFieldObject.setHeight(226);
rcd.getReportDefController().getReportObjectController().add(oFieldObject, rcd.getReportDefController().getReportDefinition().getDetailArea().getSections().getSection(0), -1);
Then I get an error (which is not unexpected)
com.crystaldecisions.sdk.occa.report.lib.ReportDefControllerException: The field was not found.---- Error code:-2147213283 Error code name:invalidFieldObject
How do I add one of the table.SetDataFields() to my report to be displayed?
Are there any other pointers or suggestions you may have?
Thank you -
Unable to create database connection using jboss
hi masters,
i have developed an application using jdeveloper ADF, and created .EAR file and deployed it in jboss. it shows that application is deployed, but when using application using URL http://localhost:8080/appl/index.jspx it opens login window, but when we enter username and password it does not authenticate user.
i am not developer, but a DBA and ask to deploy application using jboss. how can i resolve this issue??? while starting , jboss generates error "creating connection to database failed- unauthenticated login attempted"
what might be the issue?????
posting my exact error here, hope someone will post some suggestion.
MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM:
ObjectName: jboss.mq:service=PersistenceManager
state: FAILED
I Depend On: jboss.jca:service=DataSourceBinding,name=DefaultDS
Depends On Me: jboss.mq:service=DestinationManager
java.lang.SecurityException: Invalid authentication attempt, principal=null
ObjectName: jboss:service=KeyGeneratorFactory,type=HiLo
state: FAILED
I Depend On: jboss:service=TransactionManager
jboss.jca:service=DataSourceBinding,name=DefaultDS
Depends On Me: java.lang.SecurityException: Invalid authentication attempt, principal=null
ObjectName: jboss.mq:service=StateManager
state: FAILED
I Depend On: jboss.jca:service=DataSourceBinding,name=DefaultDS
Depends On Me: jboss.mq:service=DestinationManager
org.jboss.mq.SpyJMSException: Error creating connection to the database.; - nested throwable: (java.
lang.SecurityException: Invalid authentication attempt, principal=null)
ObjectName: jboss.ejb:service=EJBTimerService,persistencePolicy=database
state: FAILED
I Depend On: jboss.jca:service=DataSourceBinding,name=DefaultDS
Depends On Me: java.lang.SecurityException: Invalid authentication attempt, principal=null
any suggestion will be appreciated..
thanks and regards
VD
Edited by: vikrant dixit on १९ फ़रवरी, २००९ ९:१६ अपराह्नhello all,
do anyone have any suggestion????
thanks and regards
VD -
How to create two level dynamic list using JSP , Java Script and Oracle
I am new in JSP. And i am facing problem in creating two level dynamic list using JSP ,Java Script where the listdata will come from Oracle 10g express edition database. Is there any easy way in JSP that is available on in ASP.NET.
Plz response with details.1) Learn JDBC API [http://java.sun.com/docs/books/tutorial/jdbc/index.html].
2) Create DAO class which contains JDBC code and do all SQL queries and returns or takes ID's or DTO objects.
3) Learn Servlet API [http://java.sun.com/javaee/5/docs/tutorial/doc/].
4) Create Servlet class which calls the DAO class, gets the list of DTO's as result, puts it as a request attribute and forwards the request to a JSP page.
5) Learn JSP and JSTL [http://java.sun.com/javaee/5/docs/tutorial/doc/]. Also learn HTML if you even don't know it.
6) Create JSP page which uses the JSTL c:forEach tag to access the list of DTO's and iterate over it and prints a HTML list out.
You don't need Javascript for this. -
Create new oracle database with JAVA
Hi!
I would appreciated it if you could help me to solve a problem that i have.
I am trying to create a new oracle database by a JAVA 1.4.2 application. I am using the scripts that Oracle 10.g supplies during the creation of a new database from the server (Generate Database Creation Scripts) with the appropriate changes, generated by a java application. Unfortunately, i am unable to connect with the database and the listener. Is there any other way to create a new database by java and how can i solve my current problem with the oracle scripts?
Thank you.A) To create a new schema, you need to be connected as a user that has create schema privilege, or as tyhe user who is to own the schema (remembering that the user has appropriate create privs, as seen in the GRANT command in the SQL Reference manual). Not an issue at all, I think, if you coordinate this with your DBA. Discussed very well in the Administrator's manual.
B) Alternately, you could create a complete copy of the schema, including all desired objects (tables, views, etc.) in a separate database and simply export the user and schema. Then simply invoke the OS-based import command (imp) to load that entire thing into the target database.
C) To create a new database, there are 3 simple steps ...
1) create the appropriate initialization parameter file
the init{sid}.ora file should be placed in the $ORACLE_HOME/dbs or %ORACLE_HOME%\database directory. (I recommend you do not attempt to create the spfile.) Of critical interest will be setting the block size information, the control file parameters, and using the appropriate memory management parameters, based on the version of the software you will be using to create the database instance.
2) start an empty instance, pointing to the parameter file
This will be an OS specific call, and will require that you have the correct OS environment set up as well as access to the ORACLE_HOME which will provide the software that you will invoke. In *nix you will need to call the sqlplus command with sysdba provs and in Windows you will need to call oradim to initialize this as a service.
3) run the SQL create database command
You might want to use the dbca to create a template of the create database command, or look in the SQL Reference manual for the variations on the command. Of critical interest will be initializing the redo logs as well as the system, sysaux (if needed), temp and undo tablespaces after which you can set up the regular tablespaces, users and schemas. I highly recommend that you have redundant copies of the control files on separate drives.
You may want to review the online Concepts manual and the Adminstration Guide for some of the specifics to your needs, but I think I've covered the basics.
Remember that ideally you will only have one database instantiated on any given server as the memory and CPU overhead of each instance is significant.
Good luck. -
Login codes using java database (validates with Microsoft Access File)
hi all pro-programmer, can you show me the code to login with the username and password using java database. When the user enters the username and password in the login page then it will go to the requested page. may i know how to do it?
no one will give you complete code.
i'll lay out the pieces for you, though:
(1) start with a User object. give it username and password attributes.
(2) write a UserDAO interface with CRUD operations for a User object.
(3) write a UserDAOImpl for your Microsoft Access database
(4) write an AuthenticationService interface
(5) write an implementation of the AuthenicationService that works with the UserDAO to authorize a User.
Use a servlet to accept request from your login page and pass it off to the service. Voila.
PS - Here's skeleton to start with. UI, servlet, and controller are your responsibility:
package model;
public class User implements Serializable
private String username;
private String password;
public User(String u, String p)
this.username = u;
this.password = p;
public String getUsername() { return username; }
public String getPassword() { return password; }
public interface UserDAO
public User findByUsername(String username);
public void saveOrUpdate(User user);
public void delete(User user);
public class UserDAOImpl implements UserDAO
private Connection connection;
public UserDAOImpl(Connection connection)
this.connection = connection;
public User findByUsername(String username)
String password = "";
// logic for querying the database for a User
return new User(username, password);
public void saveOrUpdate(User user)
// save or update a User
public void delete(User user)
// delete a User
public interface AuthenticationService
public boolean isAuthorized(String username);
public class AuthenticationServiceImpl implements AuthenticationService
private UserDAO userDAO;
public AuthenticationServiceImpl()
// Create a database connection here and the UserDAO, too.
public boolean isAuthorized(String username)
boolean isAuthorized = false;
// Add logic to do the database query and decide if the username is authorized
return isAuthorized;
}
Maybe you are looking for
-
Adobe Form not getting displayed in WebDynpro Modal Window
Hi, I am trying to display the table data in a Interactive Form. I have used TABLE UI element in Interactive Form. When the user clicks on a EXPORT button this form is displayed in a pop up window (Modal Window). This form is not getting displayed fo
-
Mid 2008 Macbook Pro 15" doesn't turn on
Hi everyone, I have come to these boards pretty much out of desperation. My MBP died on me yesterday and I'm looking for ideas on how to fix it. I guess I'm hoping I can find a solution other than having to replace the motherboard as I'm quite fond o
-
Hi, I need to do Warranty Process for Vendor(Transaction wise). 1.When I am raising a Purchase Order to Vendor for the material which is in the Warranty Period, the system should allow to raise PO without Price(Free Item is disabled) 2.In case of ser
-
Getting error while using UTL files
hi All, I'm getting following error - ORA-29282: invalid file ID ORA-06512: at "SYS.UTL_FILE", line 774 ORA-06512: at "IMPORT_NEW", line 781 ORA-01722: invalid number To used UTL i have done following steps - 1. created directory 2. grant read, write
-
Force firefox to open links in a new window
How can I force firefox to open a link in a new window? Right now it opens the link in the same window, no matter how I configure the settings. Frustrating. Thanks