JDBC ORACLE SQL
in the oracle database, i have a table with 3 fields which are Number, flag and date
NBR(data type NUM) flag (data type char) todaysdate (data type Date)
i want to update the table with system current date using prepared statement.
String sql = "UPDATE TABLE_NAME SET FLAG = 'Y' TODAYSDATE =sysdate WHERE NBRO = ?"
PreparedStatement preStmt = conn.prepareStatement(sql);
preStmt.setInteger(1,input.getInteger("NBR"));
preStmt.executeUpdate();
i am getting the error below.
Cannot convert field NBR of type NUM to integer...
I would appreciate if some one could help me to figure out the problem...
Thanks,
Hi,
The object input that you are using fails to convert NBR to integer it seems.
In the JDBC spec it shows (in the appendix) the recommended conversions from SQL Types to java types.
It's best to check there and see what java type your NBR field maps to. Use that getXXX and setXXX methods instead.
Best,
Guy
http://www.atomikos.com - Insure your data with TransactionsJTA
Similar Messages
-
Configuring RAC-aware JDBC connection in Oracle SQL Developer?
How can Oracle SQL Developer be configured to properly connect to an [Oracle RAC|http://en.wikipedia.org/wiki/Oracle_RAC] environment, I.E., not just setup to always connect to one of the individual nodes?
[http://programmersjournal.blogspot.com/2008/08/jdbc-connection-string-for-oracle-rac.html] has an example of a classic and the equivalent RAC-aware version of a JDBC connection string. I've already been using a RAC connection string of the same format from within custom Java applications without issue. I thought the same should be configurable in Oracle SQL Developer by setting the "Connection Type" drop-down to "Advanced", then entering the RAC-aware JDBC connection string as the "Custom JDBC URL". However, upon testing the connection, the following error is displayed at the bottom of the dialog:
Status : Failure -Test failed: Io exception: NL Exception was generated
There is no additional information shown on the "Logging Page" view. Using Oracle SQL Developer 1.5.5.
Thanks!Thanks, Barry. Just F.Y.I., it is working for me now that I upgraded to the 2.1 EA as -K- suggested. I had marked his reply as "Correct", but probably should have left a response indicating my success as well.
Now, if there's anything you could do regarding the [issues around the display performance of CLOBs, etc., in the Query Result view|http://forums.oracle.com/forums/message.jspa?messageID=3906571] , it'd be very appreciated! -
Oracle.sql.* with JDBC drivers 8.0.5
the oracle.sql package is not included in my JDBC driver file classes111.zip given for oracle data server version 8.0.5.
I would like to use the oracle STRUCT and ARRAY type for calling PL/SQL stored procedures taking STRUCT objects in arguments.
Are the JDBC drivers 8.1.* compatible with the oracle data server 8.0.5 (if I only use the STRUCT or ARRAY types)? Is it a way for passing ARRAY of VARCHAR2 values to PL/SQL stored procedure with the oracle 8.0.5 JDBC driver?
thanksUnfortunately, these classes (oracle.sql.STRUCT and oracle.sql.ARRAY) are not compatible to 8.0 database. There is server format changes between 8.1 and 8.0, and JDBC driver only supports the 8.1 format.
Please upgrade your database to 8i. -
Problem to establish connection between Oracle SQL and JDBC
Hi friends i have been trying this code from two days i donno whats wrong please try to sort the problem thank u in advance this is my program:
//This is my Connection class
package com.java.jdbc.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class EmployeeUtil {
public EmployeeUtil()
public static Connection getconnection()
Connection con=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORANT","system","manager");
// Class.forName("sun.jdbc.odbc.OracleDriver").newInstance();
// con = DriverManager.getConnection("jdbc:odbc:Javatut","System","manager");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return con;
//This is my DB class:
package com.java.jdbc.DB;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.java.jdbc.info.EmployeeInfo;
import com.java.jdbc.util.EmployeeUtil;
public class EmployeeDB {
Connection connection=null;
public EmployeeDB()
//this.connection=EmployeeUtil.getconnection();
public void select(EmployeeInfo empinfo)
this.connection=EmployeeUtil.getconnection();
String stb = "select * from employee";
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(stb);
System.out.println(rs);
//EmployeeInfo empinfo = new EmployeeInfo();
while(rs.next())
empinfo.setEmpId(rs.getString(1));
empinfo.setEmpfName(rs.getString(2));
empinfo.setEmplName(rs.getString(3));
empinfo.setEmpAge(rs.getString(4));
empinfo.setEmpSalary(rs.getString(5));
System.out.println("The EmployeeID is : "+empinfo.getEmpfName());
System.out.println("The Employee First Name is : "+empinfo.getEmpfName());
System.out.println("The Employee Last Name is : "+empinfo.getEmplName());
System.out.println("The Employee Age is : "+empinfo.getEmpAge());
System.out.println("The Employee Salary is : "+empinfo.getEmpSalary());
connection.commit();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
//This is my info object
package com.java.jdbc.info;
public class EmployeeInfo {
private String empId;
private String empfName;
private String emplName;
private String empAge;
private String empSalary;
public String getEmpAge() {
return empAge;
public void setEmpAge(String empAge) {
this.empAge = empAge;
public String getEmpfName() {
return empfName;
public void setEmpfName(String empfName) {
this.empfName = empfName;
public String getEmpId() {
return empId;
public void setEmpId(String empId) {
this.empId = empId;
public String getEmplName() {
return emplName;
public void setEmplName(String emplName) {
this.emplName = emplName;
public String getEmpSalary() {
return empSalary;
public void setEmpSalary(String empSalary) {
this.empSalary = empSalary;
//This is my Controller class:
package com.java.jdbc.controller;
import com.java.jdbc.DB.EmployeeDB;
import com.java.jdbc.info.EmployeeInfo;
public class EmployeeController {
public static void main(String args[])
EmployeeDB empdb = new EmployeeDB();
EmployeeInfo emp = new EmployeeInfo();
empdb.select(emp);
// I got these errors:
java.sql.SQLException: Io exception: Got minus one from a read call
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:210)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:251)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:224)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.java.jdbc.util.EmployeeUtil.getconnection(EmployeeUtil.java:18)
at com.java.jdbc.DB.EmployeeDB.select(EmployeeDB.java:20)
at com.java.jdbc.controller.EmployeeController.main(EmployeeController.java:11)
Exception in thread "main" java.lang.NullPointerException
at com.java.jdbc.DB.EmployeeDB.select(EmployeeDB.java:23)
at com.java.jdbc.controller.EmployeeController.main(EmployeeController.java:11)Are you using Oracle 10.2 in shared server configuration under Windows?
If so it's a driver bug (BUG - Connection pooling with 10g 10.1.3 Preview 4 App Server Oracle suggest to use OCI driver. -
Problem etablishing connection between oracle SQL and JDBC
Hi friends i have been trying this code from two days i donno whats wrong please try to sort the problem thank u in advance this is my program:
//This is my Connection class
package com.java.jdbc.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class EmployeeUtil {
public EmployeeUtil()
public static Connection getconnection()
Connection con=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORANT","system","manager");
// Class.forName("sun.jdbc.odbc.OracleDriver").newInstance();
// con = DriverManager.getConnection("jdbc:odbc:Javatut","System","manager");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return con;
//This is my DB class:
package com.java.jdbc.DB;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.java.jdbc.info.EmployeeInfo;
import com.java.jdbc.util.EmployeeUtil;
public class EmployeeDB {
Connection connection=null;
public EmployeeDB()
//this.connection=EmployeeUtil.getconnection();
public void select(EmployeeInfo empinfo)
this.connection=EmployeeUtil.getconnection();
String stb = "select * from employee";
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(stb);
System.out.println(rs);
//EmployeeInfo empinfo = new EmployeeInfo();
while(rs.next())
empinfo.setEmpId(rs.getString(1));
empinfo.setEmpfName(rs.getString(2));
empinfo.setEmplName(rs.getString(3));
empinfo.setEmpAge(rs.getString(4));
empinfo.setEmpSalary(rs.getString(5));
System.out.println("The EmployeeID is : "+empinfo.getEmpfName());
System.out.println("The Employee First Name is : "+empinfo.getEmpfName());
System.out.println("The Employee Last Name is : "+empinfo.getEmplName());
System.out.println("The Employee Age is : "+empinfo.getEmpAge());
System.out.println("The Employee Salary is : "+empinfo.getEmpSalary());
connection.commit();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
//This is my info object
package com.java.jdbc.info;
public class EmployeeInfo {
private String empId;
private String empfName;
private String emplName;
private String empAge;
private String empSalary;
public String getEmpAge() {
return empAge;
public void setEmpAge(String empAge) {
this.empAge = empAge;
public String getEmpfName() {
return empfName;
public void setEmpfName(String empfName) {
this.empfName = empfName;
public String getEmpId() {
return empId;
public void setEmpId(String empId) {
this.empId = empId;
public String getEmplName() {
return emplName;
public void setEmplName(String emplName) {
this.emplName = emplName;
public String getEmpSalary() {
return empSalary;
public void setEmpSalary(String empSalary) {
this.empSalary = empSalary;
//This is my Controller class:
package com.java.jdbc.controller;
import com.java.jdbc.DB.EmployeeDB;
import com.java.jdbc.info.EmployeeInfo;
public class EmployeeController {
public static void main(String args[])
EmployeeDB empdb = new EmployeeDB();
EmployeeInfo emp = new EmployeeInfo();
empdb.select(emp);
// I got these errors:
java.sql.SQLException: Io exception: Got minus one from a read call
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:210)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:251)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:224)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.java.jdbc.util.EmployeeUtil.getconnection(EmployeeUtil.java:18)
at com.java.jdbc.DB.EmployeeDB.select(EmployeeDB.java:20)
at com.java.jdbc.controller.EmployeeController.main(EmployeeController.java:11)
Exception in thread "main" java.lang.NullPointerException
at com.java.jdbc.DB.EmployeeDB.select(EmployeeDB.java:23)
at com.java.jdbc.controller.EmployeeController.main(EmployeeController.java:11)Are you using Oracle 10.2 in shared server configuration under Windows?
If so it's a driver bug (BUG - Connection pooling with 10g 10.1.3 Preview 4 App Server Oracle suggest to use OCI driver. -
Accessing MySQL InnoDB tables via JDBC using Oracle SQL Developer
I had posted a problem in the Oracle SQL Developer forum with how that application (v1.1) accesses MySQL InnoDB tables and someone replied that the "[data migration] team created the integration with MySQL", so I am posting here in hopes of learning more about the problem.
Here's a summary:
When I use Oracle SQL Developer to query MySQL InnoDB tables, I need to issue a "commit" before I do each query to ensure that I am getting current results. Otherwise, it appears to be using a snapshot as-of the last commit. Is this a problem with SQL Developer, or a JDBC configuration, or MySQL problem even?
The full details are here:
Re: MySQL InnoDB tablesHi,
I've posted a response to your original thread.
Regards,
Dermot. -
I am using oracle as database and weblogic 4.5. I have copied the classes12.zip file in lib directory of weblogic. I am getting the error that oracle.sql.* and oracle.jdbc.driver.* not found when i am importing these packages in a jsp file. what i need to do to import oracle driver packages?I put it in the classpath also.
Please Advice!
Thanks in advance
AnuPamaHi Anupama,
First of all I would be surprised if you would not like to use the connection pooling feature of weblogic (in which case you might not be needing the import the classes directly), and would like to open direct connections to your database. Anyways for doing that I would recommend you to check out the readme doc that ships
along with the jdbc oracle (classes12.zip etc). I am giving an excerpt over here:
These are a few simple things that you should do in your JDBC program:
1. Import the necessary JDBC classes in your programs that use JDBC.
For example:
import java.sql.*;
import java.math.*;
2. Register the Oracle driver before before calling other JDBC APIs.
(This is not needed if you are using the JDBC Server-side Internal
Driver because registration is done automatically in the server.)
To register the Oracle driver, make sure the following statement
is executed at least once in your Java session:
DriverManager.registerDriver(
new oracle.jdbc.driver.OracleDriver());
3. Open a connection to the database with the getConnection call.
Different connection URLs should be used for different JDBC
drivers. The following examples demonstrate the different URLs.
For the JDBC OCI8 Driver:
Connection conn = DriverManager.getConnection(
"jdbc:oracle:oci8:@<database>",
"scott", "tiger");
where <database> is either an entry in tnsnames.ora or a SQL*net
name-value pair.
For the JDBC Thin Driver, or Server-side Thin Driver:
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@<database>",
"scott", "tiger");
where <database> is either a string of the form
<host>:<port>:<sid> or a SQL*net name-value pair.
For the JDBC Server-side Internal Driver:
Connection conn = DriverManager.getConnection(
"jdbc:oracle:kprb:");
Note that the trailing ':' character is necessary. When you use
the Server-side Internal Driver, you always connect to the
database you are executing in. You can also do this:
Connection conn
= new oracle.jdbc.driver.OracleDriver().defaultConnection();
Hope this helps,
Thanks,
Anupama wrote:
I am using oracle as database and weblogic 4.5. I have copied the classes12.zip file in lib directory of weblogic. I am getting the error that oracle.sql.* and oracle.jdbc.driver.* not found when i am importing these packages in a jsp file. what i need to do to import oracle driver packages?I put it in the classpath also.
Please Advice!
Thanks in advance
AnuPama--
Apurb Kumar -
Obtaining an oracle.sql.STRUCT through a pooled JDBC connection
Hello,
I am using WebLogic Server 10 and and Oracle 10 and I am trying to obtain a vendor-specific oracle.sql.STRUCT from a ResultSet using a pooled connection defined in Weblogic. I need the vendor-specific object, rather than simply the java.sql.Struct implementation, because a third party library requires it.
What gets returned in the ResultSet is a non-exposed WebLogic wrapper object which implements java.sql.Struct, but which cannot be cast to an oracle.sql.STRUCT. I can use reflection on this object to find and call the getVendorObj() method to obtain the oracle.sql.STRUCT, but this solution is not acceptable because this is not a published API and is not guaranteed not to change in future versions.
How can I reliably obtain a vendor-specific implementation of java.sql.Struct through a WebLogic connection pool in WebLogic Server 10?
Thanks for any advice,
-Dan Schwemleindan schwemlein wrote:
Joe,
Thanks again. With your guidance, I have arrived at the following approach, which I'll post for the benefit of others, and which I'd be thankful if you would validate:
1) Import the jar com.bea.core.datasource-1.0.0.0.jar from %BEA_HOME%\modules, which is the only location of the class WLConnection, which is the only class with the getVendorConnection() method you refer to.
2) Get the logical connection from the pooled data source, cast it to a WLConnection, call getVendorConnection() to obtain an OracleConnection (from the ojdbc jar), and use this connection to obtain the required oracle.sql.STRUCT from an OracleResultSet.
3) Be aware of the limitations and follow the guidelines in the document http://e-docs.bea.com/wls/docs81/jdbc/thirdparty.html#1043646 regarding security, error handling, releasing resources (close only the logical connection), etc.
Does this sound like the approach you had in mind?
Thanks again,
-Danyes.
Joe
>
Re: Obtaining an oracle.sql.STRUCT through a pooled JDBC connection
Posted: Jul 16, 2007 3:21 PM
dan schwemlein wrote:
Thanks for the quick response!I was working today...
Thank you for the information about the connection being closed.
I will look into using this configuration setting.
You say that you can describe a way to get a handle on an unwrapped
pool object using some documented WLS-specific code. Are you referring
here to the getVendorConnection() method?yes.
This method does not help me
get the oracle.sql.STRUCT object, because even the connection returned
by getVendorConnection() returns a wrapped WL java.sql.Struct object
from a call to getObject().I don't believe it. If you are running in WLS, with a local pool,
the getVendorConnection() will give you the Oracle connection,
which will give you an Oracle statement, etc, down to an oracle
STRUCT object. Once you have a direct reference to the oracle connection,
we're not in the picture when it returns something to you.
It would be great if getVendorObj() were
documented and could be counted on in future versions. To use this
method, one would still have to access it via Java reflection, because
the wrapper class and its getVendorObj() method would be exposed in an
API, correct? Could this method be exposed in the API, so that reflection
doesn't need to be used, or it is exposed somewhere that isn't documented?getVendorObj() is not yet exposed or therefore supported for the general
wrapped object, so you would have to start from the connection and
derive all subobjects from it.
Thanks again,
-Dan Schwemlein
Hello,
I am using WebLogic Server 10 and and Oracle 10 and I am trying to obtain a
vendor-specific oracle.sql.STRUCT from a ResultSet using a pooled connection
defined in Weblogic. I need the vendor-specific object, rather than simply
the java.sql.Struct implementation, because a third party library requires it.
What gets returned in the ResultSet is a non-exposed WebLogic wrapper object
which implements java.sql.Struct, but which cannot be cast to an oracle.sql.STRUCT.
I can use reflection on this object to find and call the getVendorObj() method to
obtain the oracle.sql.STRUCT, but this solution is not acceptable because this is
not a published API and is not guaranteed not to change in future versions.Understood. We all benefit from sticking to the J2EE standards,
but we could also wish Oracle had done so with it's driver objects.
I will assume your code is running in the WebLogic server, because
an external JVM can never access the real driver object, which will
always really be in the WLS JVM. No active JDBC object is serializable.
How can I reliably obtain a vendor-specific implementation of java.sql.Struct
through a WebLogic connection pool in WebLogic Server 10?There is no way to get a handle on an unwrapped pool object without using some
WLS-specific code, though I can describe a way with documented methods,
and/or I can get our documentation altered to say we'll support the
getVendorObj() method. We introspect every vendor object, and for those
implementations that have done the wise thing, projecting any non-standard
methods as an Interface, we are able to also project that Interface so
the vndor example code should work. However, in some poorly-done
cases, such as for some Oracle stuff, there is either no Interface,
or the Oracle code has extensions that take java.sql objects as input,
(at least that's the signature of the method) but two lines into the
method, the Oracle code assumes and casts the java.sql object to a concrete
Oracle object. In these use cases you need the direct unwrapped object.
We provide and document Connection.getVendorConnection(), and intend
getVendorObj() to serve the same for subobjects, but note the dangers
and responsibilities: We rely on our wrappers to implement the security
and thread-safety of our pooling system. Because user code can get
unrestricted access to the actual connection from most JDBC objects,
we can never trust that we have complete control once a vendor object
is exposed. Therefore, by default we will close and replace every JDBC
connection so exposed, as soon as the current thread is finished with
the pool connection. This hurts performance. We also document a pool
config setting that will tell us that you take responsibility for any such
problems, and not to close connections just because they've been exposed.
HTH,
Joe
Thanks for any advice,
-Dan Schwemlein -
Hi,
I am facing following issue in my one environment. but in other environment same class path is working fine. I have compared all jar and classpath for both weblogic server.
I am using weblogic 11g.
27 Mar 2013 15:21:09,507 ERROR XXXServlet:293 - oracle.sql.ARRAY incompatible with weblogic.jdbc.vendor.oracle.OracleArray
java.lang.ClassCastException: oracle.sql.ARRAY incompatible with weblogic.jdbc.vendor.oracle.OracleArray
at com.emc.nems.wsd.ui.beans.reports.mpapi.FacilityBeanType.nullSafeGet(FacilityBeanType.java:126)
at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:128)
at org.hibernate.type.AbstractType.hydrate(AbstractType.java:105)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2114)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1404)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1332)
at org.hibernate.loader.Loader.getRow(Loader.java:1230)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:603)
at org.hibernate.loader.Loader.doQuery(Loader.java:724)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1723)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at com.emc.nems.oms.dao.hibernate.util.OMSHibBaseDAO.executeNamedQueryWithoutTransaction(Unknown Source)
at com.emc.nems.wsd.dao.hibernate.reports.mpapi.MpapiReportHibDAO.findMCR020(Unknown Source)
at com.emc.nems.wsd.ui.handler.reports.ReportsHandler.getMPAPIData(Unknown Source)
at com.emc.nems.wsd.ui.servlets.reports.mpapi.MpapiServlet.executeReport(XXXServlet.java:1009)
at com.emc.nems.wsd.ui.servlets.reports.mpapi.MpapiServlet.generateAuditFile(XXXServlet.java:318)
at com.emc.nems.wsd.ui.servlets.reports.mpapi.MpapiServlet.execute(XXXServlet.java:273)
at com.emc.nems.wsd.ui.servlets.reports.mpapi.MpapiServlet.doGet(XXXServlet.java:207)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3731)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3695)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2285)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2184)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1459)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
Regards,
AbhishekCreating my Oracle connection works fine ... code as follows:
<i>Context ctxt = getInitialContext();
DataSource dataSource = (DataSource) ctxt.lookup(poolName);
Connection conn = dataSource.getConnection();
OracleConnection oracleConn = (OracleConnection)((WLConnection)conn).getVendorConnection();</i>
I also have reviewed documentation:
http://e-docs.bea.com/wls/docs81/jdbc/thirdparty.html. In section 'Using OracleStruct Extension Methods' it highlights that
<i>java.sql.Struct struct =(weblogic.jdbc.vendor.oracle.OracleStruct)(rs.getObject(2));</i>
None of the documentation actually mentions <b>oracle.sql.STRUCT</b>. For Weblogic to truely provide support for Oracle it needs an easy way of converting to this data type. At present I cannot interact with Oracle APIs until I can create an oracle.sql.STRUCT. -
How can I access the oracle/sql server jdbc driver class files from my cust
I have a war file in which I have custom DataSource i.e mypackage.Datasource class. Its basically the need of my application. In this class we connect to datasource and link some of our programming artifacts .
I have deployed the oracle jdbc driver and deploy my application as ear with datasources.xml in the meta inf file. Inspite of that my code fails to load the jdbc driver classes.
Here is the extract of the code :
Class.forName("oracle.jdbc.OracleDriver").newInstance();
String url = "jdbc:oracle:thin:@dataserver:1521:orcl";
Connection conn = DriverManager.getConnection(url, "weblims3", "labware");
if(conn != null){
out.println("the connection to the database have been achieved");
out.println("conn object achived= " + conn);
Class.forname fails in this case. I can see the ojdbc5.jar the driver jar in usr\sap\CE1\J00\j2ee\cluster\bin\ext\ojdbc5 . I even put the ojdbc.jar in web-inf/lib and application lib but does not help at all. Hope I have explained my problem clearly.
I deployed the jdbc driver in the name of ojdbc5 .
I am stuck here. It will be great help if anyone can help me in this. Thanks in advance.Bent,
You can access the database from your Java portlet, just like from any other Java/JSP environment. Yes, you can use JDBC, as well as BC4J.
The Discussion Forum portlet was built using BC4J, take a look at it's source to see how it was done.
Also, check out Re: BC4J Java portlet anyone?, it contains a lot of useful information too.
Peter -
Trying to Install RMS application 13.2.2 and I get past the pre-installation checks and when I get to the Data Source details and enter the data source details with the check box checked to validate the schema/Test Data Source I get the following error:
Error Connecting to database URL jdbc:oracle:oci:@rmsdbtst as user rms13 java.lang.Exception:UnsatisfiedLinkError encountered when using the Oracle driver. Please check that the library path is set up properly or switch to the JDBC thin client oracle/jdbc/driver/T2CConnection.getLibraryVersioNumber()
Checks performed:
RMS Application code location and directory contents:
[oracle@test-rms-app application]$ pwd
/binary_files/STAGING_DIR/rms/application
[oracle@test-rms-app application]$ ls -ltr
total 144
-rw-r--r-- 1 oracle oinstall 272 Dec 7 2010 version.properties
-rw-r--r-- 1 oracle oinstall 405 Jan 16 2011 expected-object-counts.properties
-rw-r--r-- 1 oracle oinstall 892 May 13 2011 ant.install.properties.sample
-rw-r--r-- 1 oracle oinstall 64004 Jun 6 2011 build.xml
drwxr-xr-x 9 oracle oinstall 4096 Jun 16 2011 rms13
drwxr-xr-x 3 oracle oinstall 4096 Jun 16 2011 installer-resources
drwxr-xr-x 3 oracle oinstall 4096 Jun 16 2011 antinstall
drwxr-xr-x 2 oracle oinstall 4096 Jun 16 2011 ant-ext
drwxr-xr-x 5 oracle oinstall 4096 Jun 16 2011 ant
-rw-r--r-- 1 oracle oinstall 11324 Dec 18 09:18 antinstall-config.xml.ORIG
-rwxr-xr-x 1 oracle oinstall 4249 Dec 18 10:01 install.sh
drwxr-xr-x 4 oracle oinstall 4096 Dec 18 10:06 common
-rw-r--r-- 1 oracle oinstall 16244 Dec 19 10:37 antinstall-config.xml
-rw-r--r-- 1 oracle oinstall 689 Dec 19 10:37 ant.install.log
[oracle@test-rms-app application]$
Application installation:
[oracle@test-rms-app application]$ ./install.sh
THIS IS the driver directory
Verified $ORACLE_SID.
Verified SQL*Plus exists.
Verified write permissions.
Verified formsweb.cfg read permissions.
Verified Registry.dat read permissions.
Verified Java version 1.4.2.x or greater. Java version - 1.6.0
Verified Tk2Motif.rgb settings.
Verified frmcmp_batch.sh status.
WARNING: Oracle Enterprise Linux not detected. Some components may not install properly.
Verified $DISPLAY - 172.16.129.82:0.0.
This installer will ask for your "My Oracle Support" credentials.
Preparing installer. This may take a few moments.
Your internet connection type is: NONE
Integrating My Oracle Support into the product installer workflow...
[move] Moving 1 file to /binary_files/STAGING_DIR/rms/application
Installer preparation complete.
MW_HOME=/u01/app/oracle/Middleware/NewMiddleware1034
ORACLE_HOME=/u01/app/oracle/Middleware/NewMiddleware1034/as_1
ORACLE_INSTANCE=/u01/app/oracle/Middleware/NewMiddleware1034/asinst_1
DOMAIN_HOME=/u01/app/oracle/Middleware/NewMiddleware1034/user_projects/domains/rmsClassDomain
WLS_INSTANCE=WLS_FORMS
ORACLE_SID=rmsdbtst
JAVA_HOME=/u01/app/oracle/jrockit-jdk1.6.0_45-R28.2.7-4.1.0
Launching installer...
To make sure I have connectivity from the app server to the database (on a database server) here are the steps followed:
[oracle@test-rms-app application]$ tnsping rmsdbtst
TNS Ping Utility for Linux: Version 11.1.0.7.0 - Production on 19-DEC-2013 10:41:40
Copyright (c) 1997, 2008, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = test-rms-db.vonmaur.vmc)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = rmsdbtst)))
OK (0 msec)
[oracle@test-rms-app application]$
[oracle@test-rms-app application]$ sqlplus rms13@rmsdbtst
SQL*Plus: Release 11.1.0.7.0 - Production on Thu Dec 19 10:46:18 2013
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@test-rms-app application]$
[oracle@test-rms-app application]$ ping test-rms-db
PING test-rms-db.vonmaur.vmc (192.168.1.140) 56(84) bytes of data.
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=1 ttl=64 time=0.599 ms
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=2 ttl=64 time=0.168 ms
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=3 ttl=64 time=0.132 ms
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=4 ttl=64 time=0.158 ms
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=5 ttl=64 time=0.135 ms
--- test-rms-db.vonmaur.vmc ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
rtt min/avg/max/mdev = 0.132/0.238/0.599/0.181 ms
[oracle@test-rms-app application]$
[oracle@test-rms-app application]$ uname -a
Linux test-rms-app.vonmaur.vmc 2.6.18-128.el5 #1 SMP Wed Jan 21 08:45:05 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
[oracle@test-rms-app application]$
[oracle@test-rms-app application]$ cat /etc/*-release
Enterprise Linux Enterprise Linux Server release 5.3 (Carthage)
Red Hat Enterprise Linux Server release 5.3 (Tikanga)
[oracle@test-rms-app application]$
The database is created and all the batch file scripts have been successfully deployed. Now working on the application server. The Weblogic server is installed and 11g forms and reports are installed successfully.
Any help would be helpful.
Thanks,
Ram.Please check MOS Notes:
FAQ: RWMS 13.2 Installation and Configuration (Doc ID 1307639.1) -
Oracle sql developer and access db
Hi All,
I have connection to oracle and Access dbs’ on my oracle sql developer.
When i try to create a database link from oracle db to access db i have to add Host Name.
Connection details to access looks like this :
@jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\ list.mdb;DriverID=22;READONLY=false}
I tried different variants, but it doesn’t work.
Is this possible to create database link to access db, and if yes, what i have to add for a host name and what is the syntaxes for cross table ?
Thank youGood documentation here... http://www.orafaq.com/node/60
TimS -
ClassCastException while inserting in oracle.sql.BLOB
Hi,
I have to insert a blob data in to database . I wrote the code . I'm having a ClassCastException problem in the line oracle.sql.BLOB blob = oracle.sql.BLOB.createTemporary(st.getConnection(), false,
oracle.sql.BLOB.DURATION_CALL); while trying to store a BLOB value I'm using Oracle 9i. (JDBC classes12.jar).
if I use the method with a dedicated database connection that specifies the driver as oracle.jdbc.driver.OracleDriver there is no problem .
But when I use JBoss to run , I will get ClassCastException
I imagine that somewhere in the code of this method there is a cast of the underlying connection leading to the ClassCastException when used in conjunction with the jboss datasource. The code to save the BLOB is as follows:
String sql = " update test set code = ? where id = ? ";
BLOB newBlob = BLOB.createTemporary(dbcon, false, BLOB.DURATION_CALL);
newBlob.putBytes(1,data.getBytes());
stmt = dbcon.prepareStatement(newsql);
stmt.setBlob(1, newBlob);
stmt.setInt(2, Studid );
stmt.executeUpdate();
stmt.close();Can any one tell me how can I get this code to work with the datasource implementation.
ThanksI think this could be a problem with the class loader . Take a look at this thread It should solve your problem.
http://forum.java.sun.com/thread.jspa?forumID=48&threadID=788715 -
How to specify JDBC Oracle url using deployment tool - Entity Bean
Hello I'am new to EJB.
When creating a entity bean-managed persistence and you need to specify the jdbc url with user name
and password to establish a connection object, how does one specify that in the deployment
tool?
Heres an example of what has in the J2EE tutorial has in AccountEJB to get an connection object
private String dbName = "java:comp/env/jdbc/AccountDB";
private void makeConnection() throws NamingException, SQLException {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
con = ds.getConnection();
Now if my oracle jdbc url is to be jdbc:oracle:thin:@Abe:1521:dev
ie My host is Abe, port number 1521 and database name of dev and username/password will be system/manager.
what would my dbName be at the top?
Would my JNDI lookup of a DataSource resource "java:comp/env/jdbc/AccountDB" become "java:comp/env/jdbc/dev" for starters?
In the Resource Factories Reference Code I've add a reference of
Coded Name: jdbc/dev
Type: javax.sql.DataSource
Authentication: Container
and down the bottom of the I've put JNDI Name: MyAccount
according to the AccountClient code of:
Context initial = new InitialContext();
Object objref = initial.lookup("MyAccount");
and put User Name of "system" and Password of "manager"
I'am sure in the source code I have to put
Class.forName("oracle.jdbc.driver.OracleDriver")
else you would get that no sutitable driver error, maybe you don't have to if ejb server is smart enough?
What I'am confuse about is where to specify the jdbc url of "jdbc:oracle:thin:@Abe:1521:dev" ??
Know it won't work because of this vital part. Do you have to put that somewhere else in the deployment tool or properties file, or some other tool??
Please help
Thanks
Abraham KhalilWhen running the client after successful deployment with jdbc, I'am getting
javax.naming.CommunicationException: java.rmi.MarshalException: CORBA MARSHAL 1398079699 Maybe; nested exception is:
org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : minor code: 1398079699 completed: Maybe
org.omg.CORBA.MARSHAL: Unable to read value from underlying bridge : minor code: 1398079699 completed: Maybe
at com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:923)
at com.sun.corba.ee.internal.iiop.CDRInputStream.read_value(CDRInputStream.java:281)
at com.sun.corba.ee.internal.corba.TCUtility.unmarshalIn(TCUtility.java:274)
at com.sun.corba.ee.internal.corba.AnyImpl.read_value(AnyImpl.java:554)
at com.sun.corba.ee.internal.iiop.CDRInputStream_1_0.read_any(CDRInputStream_1_0.java:605)
at com.sun.corba.ee.internal.iiop.CDRInputStream.read_any(CDRInputStream.java:252)
at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.readAny(Util.java:203)
at javax.rmi.CORBA.Util.readAny(Unknown Source)
at org.omg.stub.com.sun.enterprise.naming._SerialContextProvider_Stub.lookup(Unknown Source)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:133)
at javax.naming.InitialContext.lookup(Unknown Source)
at AccountClient.main(AccountClient.java:21)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:151)
at javax.naming.InitialContext.lookup(Unknown Source)
at AccountClient.main(AccountClient.java:21)
One thing I don't like about EJB is that everything is transparent which is good! But its much
harder to debug! :( Tried to see if I can figure it out. Hope someone has seen this problem before? -
Insert Blob column in the client errors ClassCastException: oracle.sql.BLOB
Hi,
When I try to insert and commit a Blob column(picture) I am getting the following exception.
Is there any jar I need to add or any other setup I need to do to accept the BLOB column in the olite client database.
500 Internal Server Error
javax.faces.FacesException: #{backing_XXPBWorkOrderResultsCreatePGBean.saveButton_action}: javax.faces.el.EvaluationException: java.lang.ClassCastException: oracle.sql.BLOB
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
at oracle.adf.view.faces.component.UIXCommand.broadcast(UIXCommand.java:211)
Caused by: java.lang.ClassCastException: oracle.sql.BLOB
at oracle.lite.poljdbc.LiteEmbPreparedStmt.setVal(Unknown Source)
at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
at oracle.lite.poljdbc.POLJDBCPreparedStatement.setObject(Unknown Source)
at oracle.lite.web.JupPreparedStatement.setObject(Unknown Source)
at oracle.jbo.server.BaseSQLBuilderImpl.bindUpdateStatement(BaseSQLBuilderImpl.java:1765)
at oracle.jbo.server.EntityImpl.bindDMLStatement(EntityImpl.java:7345)
With regareds,
Kali.
OSSI.Here are examples if inserting into a Blob from text, file, and retrieving a blob.
Insert into a Blob (Text)
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InsertBlob {
public static void main(String[] args) throws FileNotFoundException {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
String letterText = "some letter text";
long id = 100;
try {
DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
try {
con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
try {
stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, EMPTY_BLOB())");
stmt.setLong(1, id);
stmt.executeUpdate();
stmt = con.prepareStatement("SELECT BLOB_DATA FROM BLOB_TABLE WHERE BLOB_ID = ? FOR UPDATE");
stmt.setLong(1, id);
rs = stmt.executeQuery();
if (rs.next()) {
try {
oracle.lite.poljdbc.BLOB oliteBlob = null;
oliteBlob = ((oracle.lite.poljdbc.OracleResultSet) rs).getBLOB(1);
byte[] byteLetterText = letterText.getBytes();
oliteBlob.putBytes(1, byteLetterText);
con.commit();
} catch (ClassCastException e) {
e.printStackTrace();
} finally {
rs = null;
stmt = null;
con.rollback();
con = null;
} catch (SQLException e) {
e.printStackTrace();
}Insert Into a Blob (File)
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class InsertBlobFile {
public static void main(String[] args) throws FileNotFoundException {
Connection con = null;
PreparedStatement stmt = null;
long id = 200;
try {
DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
try {
con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
try {
stmt = con.prepareStatement("INSERT INTO BLOB_TABLE (BLOB_ID, BLOB_DATA) VALUES (?, ?)");
stmt.setLong(1, id);
File fBlob = new File ( "C:\\BLOB_TEST_FILE.TXT" );
FileInputStream is = new FileInputStream ( fBlob );
stmt.setBinaryStream (2, is, (int) fBlob.length() );
stmt.executeUpdate();
con.commit();
} catch (SQLException e) {
e.printStackTrace();
}Retrieve from Blob (Write to file)
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Blob;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class RetrieveBlob {
final static int bBufLen = 32 * 1024;
final static String outFile = "C:\\BLOB_OUTPUT_FILE.TXT";
public static void main(String[] args) throws IOException {
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try {
DriverManager.registerDriver((Driver)(Class.forName("oracle.lite.poljdbc.POLJDBCDriver").newInstance()));
try {
con = DriverManager.getConnection("jdbc:polite:polite", "system", "manager");
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
try {
stmt = con.prepareStatement("SELECT * FROM BLOB_TABLE");
rs = stmt.executeQuery();
while(rs.next()) {
int id = rs.getInt(1);
Blob value = rs.getBlob(2);
System.out.println(id + " | " + value);
writeBlobToFile(value);
} catch (SQLException e) {
e.printStackTrace();
public static long readFromBlob(Blob blob, OutputStream out)
throws SQLException, IOException {
InputStream in = blob.getBinaryStream();
int length = -1;
long read = 0;
byte[] buf = new byte[bBufLen];
while ((length = in.read(buf)) > 0) {
out.write(buf, 0, length);
read += length;
in.close();
return read;
public static long writeBlobToFile(Blob blob)
throws IOException, SQLException {
long wrote = 0;
OutputStream fwriter = new FileOutputStream(outFile);
wrote = readFromBlob(blob, fwriter);
fwriter.close();
return wrote;
}
Maybe you are looking for
-
HT5485 How do i update my iTunes on my computer so I can update my IPod?
I need to update my ipod but I first have to update itunes on my computer but I dont know how to.
-
Propose or change automatically, Employee Group and Subgroup.
Dear all, when executing an exit Action, thru transaction PA40, what's the best way to propose by default/change automatically, the employee group/subgroup? Example: I want to change the employee group from '1' (Active) to '2' (Inactive), but the fie
-
Problem Logging In - Page Can't Be Displayed
There is a chance that when you try to log onto the Forum, you may get a "Page Can't Be Displayed Error." We are actively working to fix this problem. In the meantime, if you are experiencing this problem, we have found that by returning to the forum
-
SQL Plus / Oracle - Username and Password Troubles
Hello all I have just download Oracle Database 10g Express Edition for Linux. When i use the command 'connect' with SQL Plus i am required to enter a username ans password. What is the default username and password, or where can i find it? Many thank
-
Mail crashes multiple times a day
I've been having A LOT of problems with Mail in the last few weeks. It crashes at least once a day, often multiple times a day. There are no particular causes for the crash that I notice. Sometimes, it crashes when i'm trying to read an e-mail, somet