Fahd Shariff

Ranch Hand
+ Follow
since Nov 22, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Fahd Shariff

Use a LinkedHashSet
15 years ago
This is the junk I get back. Could be a different character set. Is there any way I can set the character set in jdbc? My Oracle NLS_CHARACTERSET is WE8ISO8859P1.

�������������������������>�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������>������������������������������������>������������������������������������>������������������>���������������������������������������������������������>������������������>������������������>��� ���������������������������������>������������������������������������>������������������>������������������������������������>������������������������������������>������������������������������������>������������������������������������>������������������������������������>������������������>��������������������������������������>�������������������������������������������������������>������������������>�����������������>����������������������������������� �>������������������>������������������������������������>�����������������������������������>����������������������������������������������������������������������������������������������������������������>����������������������������������>������������������������������������>��������������������������������������������������������������������������������������������>�����������������>�����������������>������������������>�����������������>������������������& gt;�������������������/�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������'������������������������������������������������������������������������������������������������������������������������������������������������������� ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������>������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� �����������������������������>������������>������������>������������>�������>������������>������������>������������>������������>������������>������������>������������>������������>������������>������������>��������������������>������������>������������>������������>������������>������������>������������>������������>�������>������������>������������>������������>������������>������������>������������>����� �������>�������������������������������������������������������������������������������>������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������>�������������������������>����������������������������������������������>��������������������������������������������������������������������>��������������������������
I tried using setAsciiStream, but that produced junk as well:

ByteArrayInputStream bis = new ByteArrayInputStream(bigString.getBytes());
st.setAsciiStream(1, bis, bigString.getBytes().length);
I have tried various methods and finally found a couple of solutions to this problem. Please read my blog, to find out everything I tried as it is too much to post here:

Big Strings and Oracle Clobs
I've been struggling to store a huge string (7k) into an Oracle CLOB column.

This is what I have tried so far:

1.

<blockquote>code:
<pre name="code" class="java">String toStore="a long string" ;
Reader sReader = new StringReader(toStore);
int readerLength = toStore.toCharArray().length;
insertStatement.setCharacterStream(2, sReader, readerLength);
</pre>
</blockquote>


This inserts junk characters into the table with both thin and oci drivers.

2.

<blockquote>code:
<pre name="code" class="java">CLOB clob = CLOB.createTemporary(connection, true, oracle.sql.CLOB.DURATION_SESSION);
clob.trim(0);
Writer writer = clob.getCharacterOutputStream();
writer.write(toStore.toCharArray());
writer.flush();
writer.close();
insertStatement.setCLOB(2, clob);
</pre>
</blockquote>


This fails with ORA-12704: character set mismatch

3.

This consists of two steps:
a) Insert EMPTY_CLOB() into clob table
b) Select the CLOB column from the table for update and then:

<blockquote>code:
<pre name="code" class="java">oracle.sql.CLOB clob = ((oracle.jdbc.OracleResultSet) resultSet).getCLOB("clob_column");
Writer writer = clob.getCharacterOutputStream();
writer.write(toStore.toCharArray());
writer.flush();
writer.close();
</pre>
</blockquote>

This one works perfectly, but with the overhead of two calls to the database.

Does anyone have any neater way of storing a large clob object?

Any help would be appreciated!

Thanks
I have a question about loading different versions of a library dynamically at runtime.

I have two version of an external C library:

/programs/app_v1
/programs/app_v2

Currently, in my java app startup script I either:

export LD_LIBRARY_PATH=/programs/app_v1
or
export LD_LIBRARY_PATH=/programs/app_v2

depending on what version of the library I wish to load.

My question is: can I dynamically load app_v1 or app_v2 at runtime based on a user's request?
Essentially I would like to be able to switch versions without having to restart my java application.

Any help would be appreciated.

Thanks
17 years ago
A quick hack would be to convert both arrays to string representations and then use methods like indexOf or substring that come in the String class.
18 years ago
I can't see this sort method anywhere: VectorDemo.sort(0, petVector);
18 years ago
I think it should actually be:

jar -tf foo.jar 2>&1 | grep "com.mypackage.MyClass"
18 years ago
This should hopefully make things a lot clearer and neater


[ August 11, 2006: Message edited by: Fahd Shariff ]
18 years ago
This is NOT lazy initialization!

Lazy initialization would have been:



(Note: you may have problems with the above in a multi-threaded environment so it would be better to add synchronization.)
18 years ago
m(1) prints "1,"
m(2) prints "2,"
m(3) prints "3,"
m(4) prints "4,"


2%3 = 2
=> 2%3*4 = 8
=> 1+2%3*4 = 9

m(9) prints "9,"

Therefore you get: "1,2,3,4,9,"
18 years ago
Use a BufferedFileReader to read the file line-by-line.

Use a StringTokenizer or String.split to break up each line into tokens which you can then put into your table.
18 years ago
File file = new File("../Logging/note.log") ;
18 years ago
How can #5 be valid? You need a parameter name!

Test(int i){}
18 years ago