Accessing Long datatypes using JDBC
Can any body help me how to access long datatypes in JDBC. I need to store large data in String object arround 100000 length string in long. as of now with pstmt.setString(1,String ) i am able to insert 32700 length string only . how can i over come this. ?
please provide me some code for my problem .
thanks in advance.......
Which DB?
Which DB field type?
Which JDBC driver?
Similar Messages
-
How to access oracle cursors using jdbc (expecting ur earliest reply)
Hi All,
can anyone help me out by giving me an idea or sample code in accessing the cursors that are defined in the oracle... i have to access those cursors using java... Thanks in advance for your reply and time....
RaguI have tried to follow the example from the URL link you provided.
I'm using :
- Oracle 8.1.6/8.1.7
- JDK 1.3.1
I've created:
create or replace package types
as
type cursorType is ref cursor;
end;
create or replace function sp_ListEmp return types.cursortype
as
l_cursor types.cursorType;
begin
open l_cursor for
select ename, empno
from emp
order by ename;
return l_cursor;
end;
Then I have on my code the following:
import java.sql.*;
import oracle.jdbc.driver.*;
String conStatus = "":
String driver_class = "oracle.jdbc.driver.OracleDriver";
String connect_string = "jdbc:oracle:thin:@slackdog:1521:oracle8";
String query = "begin :1 := sp_listEmp; end;";
Connection conn;
Class.forName(driver_class);
conn = DriverManager.getConnection(connect_string, "scott", "tiger");
try{
conStatus = "before prepareCall, ";
CallableStatement cstmt = conn.prepareCall(query);
conStatus = conStatus + "before Register out, ";
cstmt.registerOutParameter(1,OracleTypes.CURSOR);
conStatus = conStatus + "before execute, ";
cstmt.execute();
conStatus = conStatus + "before getObject, ";
ResultSet rset = (ResultSet)cstmt.getObject(1);
while (rset.next ())
System.out.println( rset.getString (1) );
cstmt.close();
} catch (Exception e) {
conStatus = conStatus + e;
System.out.println(conStatus);
What happens is that I am able to successfully compile the code. But when I run the code, it displays:
"before prepareCall, before Register out, SQLException: incompatible types = -10."
What does that mean? Pls point out to me what I did wrong in my code.
Thanks. -
Accessing LONG datatype in Dynamic page
I've been trying to access a LONG datatype in a cursor within a dynamic page. So far portal throws the following error:
ORA-00922: missing or invalid option (WWV-11230)
when I try the following code:
<HTML>
<HEAD>
<TITLE>Dynamic Page</TITLE>
</HEAD>
<ORACLE>
SET SERVEROUTPUT ON SIZE 100000;
SET LONG 100000;
declare
v_text long;
v_crn varchar2(10);
cursor result_detail is
select r.text, r.crn
from results@mydb r
where r.id = :p1;
begin
open result_detail;
fetch result_detail into v_text, v_crn;
htp.p etc ... display data ....
close result_detail;
end;
</ORACLE>
</BODY>
</HTML>
If I leave out the SET commands it can't find the page.
Any clues? Has someone worked out how to get a LONG datatype value into Portal?
Version 902.6.18 (win 2000 server)
Thanks for any help.
PhilippeThe SWF file was developed to work in such a way as it would only look in the root directory for the XML file. Once the developer changed it so that it could access it from the same directory (regardless of what directory it was in), and then had to add 'id' and 'src' to the JavaScript function call, it worked like a charm.
^_^ -
Accessing database Variables using JDBC
Hi,
I have a question for some of you Java specialists out there.
I want to execute a select statment in my database (SQL Server 2000) and store the output in a variable. - The reason I am not directly executing the SQL statement from my JDBC connection is that I need to execute a number of SQL statements and then finally would like to store my result set in a variable in the database - NOW, my question is , how do I (If I can) access a database variable using either servlets or JSP. Any help is welcome.
A quick response would be much appreciated.
thanksWe are probably talking about different things.
ASP, at least when I used consisted of the following:
-html
-server side script (vbscript, javascript, perlscript)
-client side script (usually javascript but it could be vbscript and perlscript)
In the above you have three possible kinds of variables java, perl, vb. In each of those languages you can use SQL text to manipalate data in the database. However the text itself never ran in the ASP server nor was there such a thing a SQLscript, so there was nothing that was a SQL variable.
However, if I write a stored procedure in Oracle, it can definitely have variables. And likewise a oracle package can have variables. But there is no way to directly use those variables in ASP. The value of the variable would have to be returned to the ASP script language and a variable in tha language could contain that value.
Perhaps I just don't understand ASP or it has evolved in the last 3 years. If so then ignore everthing I have said. -
VERY URGENT: problem in sql query with long datatype in weblogic
I have a problem while tryind to retrieve a column value with a long datatype using servlet and oci driver and the server is weblogic5.1 .I have used prepared statement the problem comes in the
preparedStatement.executeQuery().
The sql Query is simple query and runs well in all cases and fails only when the long datatype column is included in the query.
The exception that comes on the weblogic server is that :
AN UNEXPECTED EXCEPTION DETECTED IN THE NATIVE CODE OUTSIDE THE VM.Did you try changing the driver then?
Please use Oracle's thin driver instead of the oci driver.
There are many advantages of using the type 4 driver. the first and foremost being that it does not require oracle client side software on your machine. Therefore no enteries to be made in tnsnames.ora
The thin driver is available in a jar called classes112.zip the class which implements the thin driver is oracle.jdbc.driver.OracleDriver
the connection string is
jdbc:oracle:thin:@<machine name>:1521:<sid>
please try out with the thin driver and let me know.
regards,
Abhishek. -
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. -
While I was insert a rows into the same table I am getting an error. I am having one long column in table list. I am getting following error while I was inserting a row.
ORA-00997: illegal use of LONG datatype
Please let me know how do I insert long data type values for this kind of insert.[duplicate thread|http://forums.oracle.com/forums/message.jspa?messageID=3770321#3770321]
-
Hi
I need to write a little server program to pass in SQL statement sent from the client and perform the statement and return the result to the client. I want to server to be able to support more than one access at a time so I will be using thread. It is where I am stuck because am I allowed to use concurrent access to database through JDBC APIs? By the way I am very new to threading etc. so any help and suggestions or directions to other resources will be appreciated.if u are using servlet then in class where u are writing service() just implement interface SingleThreadModel
write your code to make commection in that service()
java JVM automatically takes care of it ie. multiple thread
or another way is to use Connection Pooling
bye
vijaysingh -
JSP connected to MS Access using JDBC-ODBC
If I want to run a jsp file connected to a MS Access database using jdbc-odbc bridge.
I thought that I should use the following code to make the connection:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String database = "jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)}; DBQ=http://myComputerName:8080/examples/jsp/DatabaseTest/mydatabase.mdb;DriverID=22;READONLY=fals";
sqlca = DriverManager.getConnection(database, "dba","sql");
but Tomcat 4.1 produces many errors.
The file runs fine when I determine the complete path and include the local drive (C://) of the database Like the following:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String database = "jdbc:odbc:Driver={Microsoft Access Driver(*.mdb)};
DBQ=C:/Tomcat4.1/webapps/examples/jsp/DatabaseTest/mydatabase.mdb;DriverID=22;READONLY=fals";
sqlca = DriverManager.getConnection(database, "dba","sql");
Of course I do not want to use the second code because I want to use my computer as a host.
I will appreciate any answer!Yes, using the DSN, it works fine.
But, I think it will run from the drive C.
I want to use my computer as a host. So, I think that I should include the name of the computer in the path.
I do not know may I am confused.
I appreciate your reply. Thanks! -
Illegal use of LONG datatype error message when i create materialized view
Hello to all
I want create read only materialized view replication environment two of our tables have LONG datatype when i create materialized view against on them
I recieve this error message
CREATE MATERIALIZED VIEW MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID AS SELECT * FROM MDB.TOAD_PLAN_TABLE@arahisto
Error report:
SQL Error: ORA-00997: illegal use of LONG datatype
00997. 00000 - "illegal use of LONG datatype"
Do you know any resort solution for it?
thanksYou can not use longs in materialized views over a database link, you can however take a part of a long over to a materialized view.
I have gotten this to work in the past l had to create a PL/SQL function that you can use to extract the character data from the long column and use that to
as part of the function you will need to pass in the columns of the table that will identify the unique records so you can pick out the long column
example function
-- you will need to make sure this funtion is in the remote location as you can not select longs accross a DB LINK.
CREATE OR REPLACE FUNCTION MDB.TOAD_PLAN_LONG_CONV
(pass in the primary key columns for the table)
RETURN VARCHAR2
IS
v_long VARCHAR2(32767) ;
BEGIN
BEGIN
-- need to select the long column into the PL/SQL variable
SELECT long_column
INTO v_long
FROM MDB.TOAD_PLAN_TABLE
WHERE key_columns = passed columns ;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE = '-01406' THEN
NULL ;
ELSE
RAISE ;
END IF ;
END ;
RETURN SUBSTR(v_long,1,4000) ;
END ;
Then when you create the materialized view utilize that function on the long column.
create or replace materialized view MDB.TOAD_PLAN_TABLE TABLESPACE aramis REFRESH FORCE WITH ROWID
AS
SELECT column1, .... columnx,
MDB.TOAD_PLAN_LONG_CONV@arahisto (primary key column list) as long_column_name
FROM MDB.TOAD_PLAN_TABLE@arahisto ;
See if this will work for you? Keep in mind however this solution will not get the entire long column only as much as a PL/SQL variable will hold of it.
Mike -
Using Decode with "Long" datatypes
Hi,
I want to use a select statement in a view which uses a decode function involving a "long" datatype. But doing some raises an error "Invalid datatypes". Is there a way around?
Anupam.I'm a bit puzzled as to what it is you are trying to achieve (it has been an afternoon for vague requirements). Normally the sort of data that we would want to store in a LONG is ,er, long and therefore not susceptible to use in a DECODE. But it does not matter, because we can only manipulate LONGs in PL/SQL and that does not parse DECODE statements. We will have to use IF...ELSE constructs instead.
CREATE OR REPLACE FUNCTION l2v (pl in rowid) RETURN VARCHAR2
AS
ll LONG;
rv VARCHAR2(20);
BEGIN
SELECT col1
INTO ll
FROM T_LONG
WHERE rowid = pl;
IF ll LIKE '%text%'
THEN
rv := 'yes!';
ELSE
rv := 'noooo';
END IF;
RETURN rv;
END;
SQL> select l2v(rowid) from t_long;
L2V(ROWID)
yes!
yes!
SQL> You can use this function in a query. Note that it is doing a SELECT in its own right so this will not be a very performant solution if you build the view on a big table.
Cheers, APC -
Retrieving data from Microsoft Access using JDBC
I noticed that when i tried retrieving data from Microsoft access using JDBC, I realised that it was throwing SQLException when the column names were two word with spaces between them, e.g. Date Birth. But after i removed the space from the column names, my SQL queries were retrieving data. Was it because of the space in between the column names of the table?
Yeah, as far as I know having two word column names isn't allowed in SQL. There might be some way to escape it, but generally it's sensible to avoid it.
-
Error when using LONG Datatype
Hi,
I am transferring data from oracle to oracle. In my source table and target table i have a column of "long" datatype. When i execute the interface i am getting the following error.
997 : 42000 : java.sql.SQLException: ORA-00997: illegal use of LONG datatype
Cause: A value of datatype LONG was used in a function or in a DISTINCT, WHERE, CONNECT BY, GROUP BY, or ORDER BY clause. A LONG value can only be used in a SELECT clause.
How can we resolve this issue in ODI?
Thanks in Advance,
Ram Mohan TCezar,
I am bit confused with the steps.
1) Create first interface with IKM Control append and flow_control yes but no long mapping
This is the real interface to be created with out the Long Column mapping.
2) Create second interface with IKM PL/SQL and "flow_control" NO and a "not exists "filter to "E$" (from first interface)
Do I need to duplicate the same mapping here. I couldn’t understand this line Cezar. “and a "not exists "filter to "E$" (from first interface)”
Does ODI doesnt provide any direct way to resolve this issue? When ever a table with Long datatype, do we need to do this steps?
Thanks in Advance,
Ram Mohan T -
Use JDBC to Access XML Documents in Oracle XML DB
Hi folks,
From the Oracle XML DB Developer's Guide 10g Release 1 (10.1) Chapter 12 Java API for XMLType, it show several examples for how java application use JDBC to access xml in XMLDB:
1. use getOPAQUE() on XMLTYPE table/column and then call XMLTYPE.createXML();
2. use getCLOBVal()/getStringVal()/getBLOBVal() in SQL statement;
3.use getObject on the result and cast directly to XMLType;
Among these 3 options, which is supposed to be the fastest way? Any difference between thin and oci?
I have run some tests about that and the result is the second option (with thin driver) is the fastest. It surprises me because I think oci should be faster than thin. Does the result make sense?
Thanks.Have you tried to trace your sessions to see how much work is happening? Traces should give you quantifiable information on exact times and access paths to the data.
Below is a link to an O'Reilly book excerpt on Java programming with JDBC. Slightly data, but may be of assistance.
http://www.onjava.com/lpt/a//onjava/excerpt/oraclejdbc_19/index.html -
ORA-00997: illegal use of LONG datatype - while inserting a record
Hello,
I have this table:
create table TEST
USER VARCHAR2(20) not null,
WINCFG LONG RAW
There are a few records, some with user='OLDUSER'.
I want to add new records with a statement like this one:
insert into TEST
select 'NEWUSER',wincfg from TEST where user='OLDUSER'
But Oracle returns the error:
"ORA-00997: illegal use of LONG datatype"
I have no idea...
Thank youSQL> insert into TEST
2 (
3 select 'NEWUSER',wincfg from TEST where user='OLDUSER'
4 );
select 'NEWUSER',wincfg from TEST where user='OLDUSER'
ERROR at line 3:
ORA-00997: illegal use of LONG datatype
SQL> copy from scott/tiger@mydb insert test using select * from test;
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
1 rows selected from scott@mydb.
1 rows inserted into TEST.
1 rows committed into TEST at DEFAULT HOST connection.Hope it help
Maybe you are looking for
-
How can you get your ipod to play music on your ihome?
I can't get my ipod to play on my ihome is says this accesssory is not supported by ipod touch!
-
Error setting up new Managed System in SMD
Hi, we get the following error after trying to setup a new (Java)-System: DataCollect Initial Data Collect ERROR for host xyz Step DataCollect Details Initial Data Collect ERROR for host xyz !! Exception : An error occurred while uploading the Config
-
Very slow loading time - Crystal Reports Viewer 2008
Hi, I search this forum to find another thread regarding this issue. Since I've found nothing in particular, I started this one. We are currently developping a new report engine based on the .Net Crystal Report Viewer. This engine will be used i
-
Why am I getting flooded with calls from a deactivated verizon wireless number?
Im not a verizon customer, but after spending several hours on the phone with their customer support to no avail, Im turning to the community for help. The past two days Ive been flooded with calls from verizon wireless numbers in MO (mostly 636 area
-
Problem of diappeared output text as soon as page refreshes
Hi all, I have jspx page with following code <?xml version='1.0' encoding='windows-1252'?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/co