JSP and Oracle "LONG" type
I am trying to get the data from a LONG-Type field into the JSP
page.
When I write the rs.getObject(columnName), or
rs.getAsciiStream(columnName), or
rs.getString(columnName)
I would always get the following SQL error message: "Stream has
already been closed".
Do you know how to retrive the LONG data type from the results
Set?
Thank you.
Did you get any reply to this one? I am having the same problem.
Please e-mail me at [email protected]
Thanks
Madhu
Similar Messages
-
Is there a good way to model oracle object types using ERD's in designer 6i. I can only figure out how to map to tables with columns of predefined datatypes (varchar2, number, date, long). I'd like to use designer to create new datatypes. Is this possible? Thanks.
Hi Wiiliam
Sorry for the late acknowledgement (i dozed off!).. Thanks for the response. So the private instance specific to a session ensure that theres no conflict between multiple requests to the same stored proc and hence no conflict of data... Great
Chaitanya -
Database locking using JSP and Oracle database
Dear All
I am reading about how to do database locking in general and i want to implement these mechanisms using JSP pages and oracle database, but i have the following questions:-
1.If i write a “select for update” quesry in the JSP page will it locks the record ? or it will not lock the record because the connection between the JSP pages and the server will be stateless in most online systems?
2.If i write all my jave code in transaction , something like this:-
• Begin transaction
• Commit or
• Rollback
Then should i be worried about the locking issues or the database manger will handle the locking mechanisms to insure data integrity(and what the default mechanism (if any) that the oracle database manger use to do the locking)?
3. If the answer for question 2 is no, then how can i handle the optimistic and the pentemistic locking using JSP pages?
BROne way to solve this issue is as follows:
* You add a new column to each database table called 'version' which is of int type.
* Each time you alter any field in a record, you increament the version number.
* When you read a record and display it, you store the version number in your code
* when you go to update the record, you write your sql something like this:
update person set firstName=? where personId=? and version=?
Where the version is whatever you stored locally. If someone altered the record in the database while your
end user was looking at it, the version numbers will not match and the sql statement will
return zero as the number of records it altered. If its zero, inform the end user someone altered the record
while he was looking at it and weather or not he wants to proceed.
The chances of two people altering the same record in a table while both are logged in and viewing the same set of data is small so such collisions will be few.
You only need transactions if you are updating more than one record at a time (in the same table or multiple tables).
You dont need it for reading records if you use a single sql statement to read (for example: to join multiple tables).
In general, you get a (pooled) connection, use it, and close it as quickly as possible in a try/catch/finally block. You dont hold onto it for the duration of the user's session. A book on JDBC should help clarify this. -
WebLogic CMP and Oracle LONG columns
I noticed that the Oracle LONG is not supported in
http://edocs.bea.com/wls/docs61/ejb/cmp.html#1059575
but doesn't seem to cause an error when I use it in the descriptors or
column types.
Am I going to be bopped on the head down the road with hidden issues? I'm
trying to store arbitrarily (well, reasonably so) long strings? Should I use
CLOBs instead? LONG are easier to work with other database tools which is
why I'd prefer them but...
thanks,
gregThe link you've mentioned doesn't say that Oracle long is not supported. In
fact it is supported and the corresponding java data-type for WLS is
Longvarchar.
For more on this you can refer to
http://e-docs.bea.com/wls/docs61//oracle/advanced.html#1158561 under "Data
Types". Here you'll find elaborate discussion on Java supported data-types
for Oracle.
Regards,
Santanu
"Gregory Gerard" <[email protected]> wrote in message
news:3c1f0784$[email protected]..
I noticed that the Oracle LONG is not supported in
http://edocs.bea.com/wls/docs61/ejb/cmp.html#1059575
but doesn't seem to cause an error when I use it in the descriptors or
column types.
Am I going to be bopped on the head down the road with hidden issues? I'm
trying to store arbitrarily (well, reasonably so) long strings? Should Iuse
CLOBs instead? LONG are easier to work with other database tools which is
why I'd prefer them but...
thanks,
greg -
Storing / Retrieving PDF using JSP and Oracle
Dear All
I am building web application using Macromedia Dreamweaver , using JSP , Tomcat and Oracle 10gR1.
I need to build a JSP to upload a PDF file to the database and have a way to retrieve it from the database ,, all through JSP .
I need hints about the building architecture and how it is done ,, samples of code will be great.
Thank You Very MuchUse JSP, Servlet and some third party API (Apache Common File Upload) to store the PDF document in blob column.
--Balaji S -
JDBC Thin Client and Oracle Long Datatype
I am using Wepshere 4.0.2 , JDBC 2.0 (thin driver) and oracle 9i.
I have a procedure which takes Oracle Long Datatype as its parameter.
I use following code to execute procedure.
String dataforsql="AAA000000003 123123 07/01/200301/01/2003";
byte[] bytes = dataforsql.getBytes();
InputStream is = new ByteArrayInputStream(bytes);
cstmt=conn.prepareCall("call nscw.CPPF_SAVEPDCRAWTABLE2(?,?,?)");
cstmt.setAsciiStream (1, is,bytes.length);
The above code works perfectly for data upto 4000 bytes. Once the data crosses the 4000 mark.
i get a procedure error
ORA-01460: unimplemented or unreasonable conversion requestedcstmt.setAsciiStream (1, is,bytes.length);Oracle's support for CLOB (and BLOB) columns using set{Ascii,Binary}Stream() generally s*cks. You'll have to read Oracle's own JDBC manual (you can read it online at http://technet.oracle.com) for whatever sequence they recommend.
E.g. for insertion and updation of CLOBS, you're supposed to use an oracle-specific function (EMPTY_CLOB()) as the value in the INSERT/UPDATE statement, and then do a SELECT, getClob(), and use Clob APIs to update the actual column value. At least officially. Or you have to use some Oracle-specific APIs in oracle.sql.Connection and oracle.sql.CLOB. -
Generating a Web Service and Oracle DATE type
Hi,
I need to generate a Web Service from an EJB model based upon entities generated from the Oracle 11g database that contain DATE types.
I realize that java.sql.Date may not be a supported JAX-RPC type but I would be VERY grateful for some instructions about the easiest way to solve this problem when generating the web service in JDeveloper 11g.
The integrated WLS server log looks like this:
<2009-apr-26 kl 23:13 CEST> <Error> <HTTP> <BEA-101216> <Servlet: "WSEE_SERVLET" failed to preload on startup in Web application: "/SessionFacadeBean".
javax.xml.ws.WebServiceException: Unable to create JAXBContext
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:158)
at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:87)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:264)
at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:322)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:188)
Truncated. see log file for complete stacktrace
java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.sql.Timestamp does not have a no-arg default constructor.
this problem is related to the following location:
at java.sql.Timestamp
at public java.sql.Timestamp oracle.Lan.getAterlamnadDatum()
at oracle.Lan
at public java.util.List ejbmodel.jaxws.QueryLanFindByNrResponse._return
at ejbmodel.jaxws.QueryLanFindByNrResponse
..... and so on
The entity bean i question looks like this:
package oracle;
import java.io.Serializable;
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@Entity
@NamedQueries({
@NamedQuery(name = "Lan.findAll", query = "select o from Lan o"),
@NamedQuery(name = "Lan.FindByNr", query = "select o from Lan o where o.lanNr = :p_lanNr")
public class Lan implements Serializable {
@Column(name="ATERLAMNAD_DATUM")
private Timestamp aterlamnadDatum;
@Column(nullable = false)
private Long demandcount;
private Timestamp demanddate;
@Column(name="EXEMPLAR_NR", nullable = false)
private Long exemplarNr;
@Column(nullable = false)
private String isbn;
@Id
@Column(name="LAN_NR", nullable = false)
private Long lanNr;
@Column(nullable = false)
private Long remindercount;
private Timestamp reminderdate;
@Column(name="TILLBAKA_DATUM")
private Timestamp tillbakaDatum;
@Column(name="UTLANAD_DATUM")
private Timestamp utlanadDatum;
@ManyToOne
@JoinColumn(name = "PERSON_NR")
private Lantagare lantagare;Hi All,
When i'm developing EJB Webservice i am getting following error .. i think it doesn't support java.sql.Date; and java.sql.timestamp; types
the error are as show in below please suggest me.
[Running application oil on Server Instance IntegratedWebLogicServer...]
[05:04:09 AM] ---- Deployment started. ----
[05:04:09 AM] Target platform is (Weblogic 10.3).
[05:04:09 AM] Retrieving existing application information
[05:04:09 AM] Running dependency analysis...
[05:04:09 AM] Deploying 2 profiles...
[05:04:10 AM] Wrote EJB Module to C:\Documents and Settings\Administrator\Application Data\JDeveloper\system11.1.1.4.37.59.23\o.j2ee\drs\oil\oil_webservicesEJB.jar
[05:04:10 AM] Wrote Enterprise Application Module to C:\Documents and Settings\Administrator\Application Data\JDeveloper\system11.1.1.4.37.59.23\o.j2ee\drs\oil
[05:04:10 AM] Redeploying Application...
<Jun 30, 2011 5:04:10 AM EDT> <Warning> <J2EE> <BEA-160195> <The application version lifecycle event listener oracle.security.jps.wls.listeners.JpsAppVersionLifecycleListener is ignored because the application oil is not versioned.>
<Jun 30, 2011 5:04:10 AM EDT> <Warning> <Munger> <BEA-2156203> <A version attribute was not found in element webservices in the deployment descriptor in C:\Documents and Settings\Administrator\Application Data\JDeveloper\system11.1.1.4.37.59.23\o.j2ee\drs\oil\oil_webservicesEJB.jar/META-INF/webservices.xml. A version attribute is required, but this version of the Weblogic Server will assume that the JEE5 is used. Future versions of the Weblogic Server will reject descriptors that do not specify the JEE version.>
<Jun 30, 2011 5:04:10 AM EDT> <Error> <HTTP> <BEA-101216> <Servlet: "WSEE_SERVLET" failed to preload on startup in Web application: "/oil-oil_webservices-webapp".
javax.xml.ws.WebServiceException: Unable to create JAXBContext
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:164)
at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:94)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:281)
at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:363)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:202)
Truncated. see log file for complete stacktrace
Caused By: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.sql.Timestamp does not have a no-arg default constructor.
this problem is related to the following location:
at java.sql.Timestamp
>
[05:04:11 AM] #### Deployment incomplete. ####
#### Cannot run application oil due to error deploying to IntegratedWebLogicServer.
[05:04:11 AM] Remote deployment failed
[Application oil stopped and undeployed from Server Instance IntegratedWebLogicServer]
Thanks in advance..
Siva
Edited by: Shankar on Jun 30, 2011 7:02 AM -
Concurrency and Oracle Object Types
Hi All,
I have a question regarding Concurrent usage of an Object type in Oracle.
I have a java program which calls an Oracle stored proc with the object's table type as IN parameter. In my stored proc, I am populating an Oracle Object with data received from java and retrieving some data based on that.
My java program can be invoked concurrently by 500 users at the same time - the application is built to handle that request load.
Now in Oracle, if a bunch of requests are received at the same, would Oracle create multiple instances of this object type that would be usage to the multiple stored proc invocations? Or would there be a prob of concurrency?
If multiple instance creation is not supported, is there some alternative I can use?
My code roughly resembles:
Object:
contains two columns - name, age
Stored proc - logic to retrieve and return data from a table based on the name, age received.
When a bunch of requests access the stored proc simultaneously, will a bunch of instnaces of the object type get created? Or would there be a scenario where the object is common to all requests and hence data from one request would be conflicted due to data from another request?Hi Wiiliam
Sorry for the late acknowledgement (i dozed off!).. Thanks for the response. So the private instance specific to a session ensure that theres no conflict between multiple requests to the same stored proc and hence no conflict of data... Great
Chaitanya -
I have an ON INSERT trigger for a table.
Since it will be automatically triggered
upon any insert statement, and if I am not
wrong, triggers can't return any values.
Is there anyway that in my calling JSP,
I can know of whether the INSERT is successfully or not???
So that I can direct the user to the appropriate page???
Thanks...If your insert fails you will get an exception which will be returned as an error to your JSP code.
If you want to trap "soft" errors that don't cause an Oracle error, you can check for the condition in the trigger and use raise_application_error to let the caller know it failed. -
Require help on Array of Nested tables and Oracle Object type
Hi All,
I have a scenario where I have some millions of records received from a flat file and the record is stored in Table as below:
Tablename: FILE_RECORD
Rows:
FILE_REG_ID = 1
RECORD_NBR = 1
PROCESSED_IND = U
RECORD= 00120130326006A
FILE_REG_ID = 1
RECORD_NBR = 2
PROCESSED_IND = U
RECORD= 00120130326003
1) I have to read these records at once and
a) Split the RECORD column to get various other data Eg: Fld1=001, Fld2=20130326, Fld3 = 003
b) send as an Array to Java.
2) Java will format this into XML and sent to other application.
3) The other application returns a response as Successful or Failure to Java in XML
4) Java will send RECORD_NBR and the corresponding response as Success or Failure back to PLSQL
5) PLSQL should match the RECORD_NBR and update the PROCESSED_IND = P.
I 'm able to achieve this using SQL Table type by creating a TYPE for Each of the fields (Flds) however the problem is Java cannot Access the parameters as the TYPE are of COLUMN Types
Eg: For RECORD_NBR
SUBTYPE t_record_nbr IS FILE_RECORD.T010_RECORD_NBR%TYPE;
Can you please let me know how I can achieve this to support Java, I know one way that is by creating an OBJECT TYPE and a TABLE of the OBJECT TYPE.
Eg: T_FILE_RECORD_REC IS OBJECT
FILE_REG_ID number(8), RECORD_NBR number (10), PROCESSED_IND varchar2(1), RECORD varchar(20)
Create type T_FILE_RECORD_TAB IS TABLE OF T_FILE_RECORD_REC
However I'm facing a problem to populate an Array of records, I know I'm missing something important. Hence please help.
It would be helpful to provide some guidelines and suggestions or Pseudo or a Code to achieve this. Rest all I can take up further.
Thanks in advance,I know once way that is creating a OBJECT TYPE and a TABLE of OBJECT TYPE, howeve I feel I'm missing something to achieve this.You're right, you need SQL object types created at the database level. Java doesn't know about locally defined PL/SQL types
However you can do without all this by creating the XML directly in PL/SQL (steps 1+2) and passing the document to Java as XMLType or CLOB.
Are you processing the records one at a time? -
I write a oracle procedure like this:
Type retstring is Record
a varchar2(6),
b varchar(10)
type retstr is table of retstring index by BINARY_INTEGER;
procedure getStr( ret out retstr )is
begin
loop
ret(i).a := a1;
ret(i).b := b1;
end loop;
end;
I want to call the procedure in my java program.How do i define the variable? Give me an example please!!hightech wrote:
is bug!?!!?!to the original poster, this answer is not only incorrect but it is quite possibly deliberately misleading from a known forum troll. Please ignore it. -
How do you handle long strings between JSP forms and Oracle?
I am using Apache 1.3.12 with JServ 1.1 and Oracle 8.0.4 on NT4 development Server.
I am developing an application where one component allows authors to contribute articles or comments via a JSP page. I am noticing a problem when the info in the form gets too long (> 2000 characters). 99% of the inserts fall well within this limitation. The remaining 1% is sufficiently significant that I can't use a VARCHAR. It seems that SQL*NET chokes on large strings.
My immediate workaround for these messages is to break them up into segments. Instead of storing the text or a message directly in a message table, I've added another table, msg_text, with columns msg_id, seg_num, and seg_text. On insert the message is split into segments limited to the smaller of the query limit and database varchar limit, minus the overhead of the sql query. This makes for an ugly insert operation, though and I would very interested to see if anyone out there has a better way to accomplish this task directly with CLOBs.The apparent problem with LONGs is that, of course, you can only have one per table.
I had exactly this problem and ended up with several tables for one Business Entity, which is not really satisfactory.
For the next phase of the Project, I will investigate:
Putting these tables into a View.
Putting Instead Of triggers on the View to "synchronise" changes to all underlying tables.
Basing my BC4J Entity Object on the View...
... and I hope that Bob will be my uncle.
I'd be interested to hear from anyone who has already tried this, or you if you give it a go.
Rich -
Issue with Oracle LONG RAW data type
Hi All,
I am facing some issues with Oracle LONG RAW DATA Type.
We are using Oracle 9IR2 Database.
I got a table having LONG RAW column and I need to transfer the same into another table having LONG RAW column.
When I tried using INSERT INTO SELECT * command (or) CREATE TABLE as select * , it is throwing ORA-00997: illegal use of LONG datatype.
I have gone through some docs and found we should not use LONG RAW using these operations.
So I did some basic PLSQL block given below and I was able to insert most of the records. But records where the LONG RAW file is like 7O kb, the inserting is faliling.
I tried to convert LONG RAW to BLOB and again for the record where the LONG RAW is big in size I am getting (ORA-06502: PL/SQL: numeric or value error) error.
Appreciate if anyone can help me out here.
DECLARE
Y LONG RAW;
BEGIN
FOR REC IN (SELECT * FROM TRU_INT.TERRITORY WHERE TERRITORYSEQ=488480 ORDER BY TERRITORYSEQ ) LOOP
INSERT INTO TRU_CMP.TERRITORY
BUSINESSUNITSEQ, COMPELEMENTLIFETIMEID, COMPONENTIMAGE, DESCRIPTION, ENDPERIOD, GENERATION, NAME, STARTPERIOD, TERRITORYSEQ
VALUES
REC.BUSINESSUNITSEQ, REC.COMPELEMENTLIFETIMEID, REC.COMPONENTIMAGE, REC.DESCRIPTION, REC.ENDPERIOD, REC.GENERATION, REC.NAME,
REC.STARTPERIOD, REC.TERRITORYSEQ
END LOOP;
END;
/Maddy wrote:
Hi All,
I am facing some issues with Oracle LONG RAW DATA Type.
We are using Oracle 9IR2 Database.
I got a table having LONG RAW column and I need to transfer the same into another table having LONG RAW column.
When I tried using INSERT INTO SELECT * command (or) CREATE TABLE as select * , it is throwing ORA-00997: illegal use of LONG datatype.
I have gone through some docs and found we should not use LONG RAW using these operations.
So I did some basic PLSQL block given below and I was able to insert most of the records. But records where the LONG RAW file is like 7O kb, the inserting is faliling.
I tried to convert LONG RAW to BLOB and again for the record where the LONG RAW is big in size I am getting (ORA-06502: PL/SQL: numeric or value error) error.
Appreciate if anyone can help me out here.
DECLARE
Y LONG RAW;
BEGIN
FOR REC IN (SELECT * FROM TRU_INT.TERRITORY WHERE TERRITORYSEQ=488480 ORDER BY TERRITORYSEQ ) LOOP
INSERT INTO TRU_CMP.TERRITORY
BUSINESSUNITSEQ, COMPELEMENTLIFETIMEID, COMPONENTIMAGE, DESCRIPTION, ENDPERIOD, GENERATION, NAME, STARTPERIOD, TERRITORYSEQ
VALUES
REC.BUSINESSUNITSEQ, REC.COMPELEMENTLIFETIMEID, REC.COMPONENTIMAGE, REC.DESCRIPTION, REC.ENDPERIOD, REC.GENERATION, REC.NAME,
REC.STARTPERIOD, REC.TERRITORYSEQ
END LOOP;
END;
/below might work
12:06:23 SQL> help copy
COPY
Copies data from a query to a table in the same or another
database. COPY supports CHAR, DATE, LONG, NUMBER and VARCHAR2.
COPY {FROM database | TO database | FROM database TO database}
{APPEND|CREATE|INSERT|REPLACE} destination_table
[(column, column, column, ...)] USING query
where database has the following syntax:
username[/password]@connect_identifier -
ADF View Object query to use Oracle LONG data type
Hi,
I'm using a view object that uses Oracle LONG data type.The following exception is thrown
*"java.sql.SQLException: Stream has already been closed"* and it is not fetching the correct data.
I have searched in many forums,they suggested to use LOB instead of LONG as LONG is deprecated. But in my case I can't avoid using LONG as some of my legacy applications using the same DB.
Please suggest me a way
Thanks in Advance
FelixThanks for your reply Arun,
I have solved this problem using the solution suggested by this blog [AskTom-Link|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:839298816582]
In the above blog link,they have suggested to convert Long to Varchar by functions and asked to use this function in the column.
Thank you all guys who have seen this post.
Regards,
Felix -
After I open Firefox I start typing the URL. After each letter I see autocomplete suggestions. Imagine I type "g", then "o" (google is shown as autocomplete), but then I enter "a". Since I have no pages that begin with "goa", autocomplete is hidden and the problem is, I can no longer type anything. All my key strokes are now ignored (backspace, enter... it dosen't matter). But I still see the cursor blinking after "goa".
I have discovered that Firefox must be focused on some other interface element (not in the address bar), because if I press the TAB key, the focus is again shifted to the address bar and I can continue typing. Sometimes I have to press TAB 2 or 3 times while entering an address to be able to write what I want. It looks like every time autocomplete is closed, the program focus leaves the address bar.
I've been having this problem for at least 4 or 5 versions of Firefox and it does not happen on every Firefox session. It can be solved by closing Firefox and opening it again. Pressing the TAB key has become kind of a reflex, so it's just annoying and I can work around it.
But why is this happening?Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
*Do not click the Reset button on the Safe mode start window or otherwise make changes.
*https://support.mozilla.org/kb/Safe+Mode
*https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
Maybe you are looking for
-
Saving processed files in original raw (or DNG?) format
Hello. I'm new to Lightroom, so although I've spent a day or so ploughing through the tutorials, please accept my apologies if my question seems dumb. However I can't see an answer to my problem so far. It is this: after importing my raw files (CR2)
-
Problem with MSSQL 2005 maintenence plan
Hi, I am facing a problem with MSSQL 2005 maintenance plan. I created a plan which takes full backup of all the db's and in the same plan I added a clean up task which is suppose to clean all the files older that 1 day. To gain compression I converte
-
What will happen if I quit the installer?
What will happen if I quit the installer? It seems to be stuck a the last step "Time Remaining: About a minute"but the installer application is responsive. What are the consequences of quiting the installer?
-
TS3992 Having trouble with iCloud backup storage-Please help me
I am trying to setup my icloud storage backup and I have all app turned off and have turned off all other things to store as well, yet my "Next Backup Size" is saying 18.0 GB... Nothing I do will change this 18 GB. I don't have photos or music set t
-
HT1212 My iPhone has been disabled because of a forgotten passcode how can I get into my phone
My iPhone has been locked because I forgot my passcode. How can I get into my phone?