It's ok. I tried Gerd's re-mix of your patch and it seemed to work
fine. The magical Method.setAccessible(true) seems to make all the
difference :)
Cheers,
Rob
On Sun, Feb 7, 2010 at 7:15 PM, Neville Rowe <row...@ho...> wrote:
>
> Hi Robert,
>
>
>
> Okay, further investigation shows because I'm still using an Oracle 9 client (and an Oracle 9 db for a variety of silly reasons) this is a change between the Oracle 9 and Oracle 10 jdbc drivers. So my patch doesn't work for Oracle 10. And what is worse is because of a 'feature' of Java - where you have a private class implementing a method as public from public interface throws an IllegalAccessException -
>
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071593
>
> So the solution to this is to walk up the class hierarchy until you find the public superclass / interface.
>
>
>
> private void setTimezoneForSession(ISession session, OraclePreferenceBean prefs)
> {
> if (!prefs.getInitSessionTimezone())
> {
> if (s_log.isInfoEnabled())
> {
> s_log.info("setTimezoneForSession: user preference for init session timezone is disabled. "
>
> + "Local Timezone data types may not be displayed correctly.");
> }
> return;
> }
>
> Connection con = session.getSQLConnection().getConnection();
> String timezoneStr = prefs.getSessionTimezone();
> if (s_log.isInfoEnabled())
> {
> s_log.info("setTimezoneForSession: attempting to set the session timezone to : " + timezoneStr);
>
> }
> boolean done = false;
> Class here = con.getClass();
> while (here.getName().startsWith("oracle.") && !done) {
> try {
> Method setSessionTimeZoneMethod = here.getMethod("setSessionTimeZone", String.class);
> if (setSessionTimeZoneMethod != null) {
> setSessionTimeZoneMethod.invoke(con, timezoneStr);
> done = true;
> }
> } catch (Exception e)
> {
> }
> if (! done) {
> here = here.getSuperclass();
> }
> }
> if (! done) {
> s_log.error("setTimezoneForSession: Could not set session timezone.");
> }
> }
>
>
>
> Sorry about that.
>
>
>
> Neville
>
>> Date: Sat, 6 Feb 2010 16:24:35 -0500
>> From: rob...@gm...
>> To: row...@ho...
>> CC: squ...@li...
>> Subject: Re: [Squirrel-sql-develop] Classpath in Oracle Plug-in
>>
>> Hi Neville,
>>
>> I don't see how
>> con.getClass().getName().equals("oracle.jdbc.OracleConnection") will
>> ever be true, since oracle.jdbc.OracleConnection is an interface, and
>> not an implementation. For example, my driver connection classname is
>> oracle.jdbc.driver.T4CConnection. The setSessionTimeZone method
>> appears to be implemented in
>> oracle.jdbc.driver.PhysicalConnection.setSessionTimeZone, which I
>> would guess is a superclass of T4CConnection (at least this is what is
>> returned from getMethod according to the debugger). The code that you
>> suggested gives me this exception:
>>
>> java.lang.IllegalAccessException: Class
>> net.sourceforge.squirrel_sql.plugins.oracle.OraclePlugin can not
>> access a member of class oracle.jdbc.driver.PhysicalConnection with
>> modifiers "public"
>>
>> Rob
>>
>>
>> On Sat, Feb 6, 2010 at 1:48 PM, Neville Rowe <row...@ho...> wrote:
>> >
>> > Hi there,
>> >
>> > In using the Oracle plug-in, I'm getting a regular 'class not found' for oracle.jdbc.OracleConnection. The issue is there is a check in the OraclePlugin.java to load that class to use reflection to do a set Time zone. So the current code from line 489 onwards looks like
>> >
>> > Class oraConClass = Class.forName("oracle.jdbc.OracleConnection");
>> > Method setSessionTimeZoneMethod = oraConClass.getMethod("setSessionTimeZone", String.class);
>> > if (setSessionTimeZoneMethod != null)
>> > {
>> > setSessionTimeZoneMethod.invoke(con, timezoneStr);
>> > } else
>> > {
>> > s_log.error("setTimezoneForSession: setSessionTimeZoneMethod returned by reflection was null. "
>> > + "Skipped setting session timezone");
>> > }
>> >
>> > The issue is if the jdbc driver is loaded through the extra classpath, then Class.forName doesn't find it.
>> >
>> > Wouldn't this be better....
>> >
>> > if (con.getClass().getName().equals("oracle.jdbc.OracleConnection")) {
>> > Method setSessionTimeZoneMethod = con.getClass().getMethod("setSessionTimeZone", String.class); if (setSessionTimeZoneMethod != null)
>> > {
>> > setSessionTimeZoneMethod.invoke(con, timezoneStr);
>> > } else
>> > {
>> > s_log.error("setTimezoneForSession: setSessionTimeZoneMethod returned by reflection was null. "
>> > + "Skipped setting session timezone");
>> > }
>> > }
>> >
>> > Suggestions ?
>> >
>> > Neville
>> >
>> > _________________________________________________________________
>> > Do you have a story that started on Hotmail? Tell us now
>> > http://clk.atdmt.com/UKM/go/195013117/direct/01/
>> > ------------------------------------------------------------------------------
>> > The Planet: dedicated and managed hosting, cloud storage, colocation
>> > Stay online with enterprise data centers and the best network in the business
>> > Choose flexible plans and management services without long-term contracts
>> > Personal 24x7 support from experience hosting pros just a phone call away.
>> > http://p.sf.net/sfu/theplanet-com
>> > _______________________________________________
>> > Squirrel-sql-develop mailing list
>> > Squ...@li...
>> > https://lists.sourceforge.net/lists/listinfo/squirrel-sql-develop
>> >
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the business
>> Choose flexible plans and management services without long-term contracts
>> Personal 24x7 support from experience hosting pros just a phone call away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Squirrel-sql-develop mailing list
>> Squ...@li...
>> https://lists.sourceforge.net/lists/listinfo/squirrel-sql-develop
>
> _________________________________________________________________
> Do you have a story that started on Hotmail? Tell us now
> http://clk.atdmt.com/UKM/go/195013117/direct/01/
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Squirrel-sql-develop mailing list
> Squ...@li...
> https://lists.sourceforge.net/lists/listinfo/squirrel-sql-develop
>
|