Question

oracle 9.2.0.5 thin driver problem

Asked by: manojvelliyatt

Hi All,

i am facing a problem with oracle 9.2.0.5 thin drivers.

we have got a third party software that was displaying the date in the following
format with  oracle9.2.0.5 and 9.0.1.4 driver
     2004-12-08 21:15:10


But when i changed the driver to 9.2.0.5 with oracle9.2.0.5 and 9.2.0.5 driver.
it is displaying the date in following format
     11/15/2004 15:15:55
     
i don't have any access to the code for checking which way it is displaying date.

i have written one Java Client for investgating some point.
i am attaching the same here and output of that.but i am not able to conclude any thing Can somebody help me out.


import java.util.*;
import java.io.*;
import javax.sql.*;
import java.sql.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import oracle.jdbc.OracleStatement;
import java.text.*;
public class DateTest
{
    public static void main(String args[])
    {
        DateTest DT = new DateTest();
    }

    public DateTest()
    {

        try
        {
            System.out.println("######"+getLastUpdatedTime(new Hashtable())+"######");

        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
    }


    private Connection getNormalConnection() {

        Connection con = null;
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            con = DriverManager.getConnection(
                  "jdbc:oracle:thin:@172.26.248.39:1522:SLAM01", "LAMSYSA_SLAM", "LAMSYSA_SLAM");

            }
         catch (Exception e) {
            e.printStackTrace();
        }

        return con;

    }


    /**
    * Gets the SLAM Database Connection
    *
    * @param Map connDetails
    * @return Connection object for SLAM db
    */
    private Connection getConnection(Map connDetails) {

        Connection conn = null;
        //could make a get connection method as we do this again in another
         final Hashtable properties = new Hashtable();
        try {
         properties.put(Context.INITIAL_CONTEXT_FACTORY,
         weblogic.jndi.WLInitialContextFactory.class.getName());
         properties.put(Context.PROVIDER_URL,"t3://10.248.19.11:7010");
         InitialContext ctx = new InitialContext(properties);

            DataSource ds =
                (javax.sql.DataSource) javax.rmi.PortableRemoteObject.narrow(
                        ctx.lookup("JNDI_LAM"), javax.sql.DataSource.class);

            conn =  ds.getConnection();
        }
         catch (Exception e) {
            e.printStackTrace();
        }

        return conn;

    }
    private long getLastUpdatedTime(Map connDetails)
    {
        System.out.println("#####getLastUpdatedTime######");
        //DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);

        String query = "select * FROM NLS_SESSION_PARAMETERS";
        DateFormat df = DateFormat.getDateInstance();
        java.sql.Date updatedDate = null;
        Time time = null;
        Timestamp s = null;
        Connection objConnection = null;
        String updatedTimeQuery = null;
        PreparedStatement psUpdatedTimeQuery = null;
        ResultSet rsUpdatedTimeQuery = null;
        ResultSetMetaData rsMetadata = null;
        Statement stmt = null;
        ResultSet rs = null;
        //System.out.println("SRS-->"+srs.getString(1));

        //Normal one

        Connection con = getNormalConnection();
        Statement norstmt = null;
        ResultSet norrs = null;
        //NLS_SETTING

        Statement nlsstmt = null;
        ResultSet nlsrs = null;



        ResultSetMetaData rsmd = null;
        String update = null;

        try
        {


            objConnection = getConnection(connDetails);
            //updatedTimeQuery = "SELECT updatedDATE FROM Page";
            updatedTimeQuery = "SELECT sysdate from dual";
            stmt = objConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                                 ResultSet.CONCUR_READ_ONLY);
            //((OracleStatement)stmt).defineColumnType(1, Types.VARCHAR);
            //stmt.executeQuery("alter session set NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
            //stmt.close();
            stmt = objConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
                                                 ResultSet.CONCUR_READ_ONLY);
            System.out.println("Statement Scroll --> " +  stmt.getClass().getName());
            rs = stmt.executeQuery(updatedTimeQuery);
            System.out.println("Column Scroll Class Name "+rs.getMetaData().getColumnClassName(1));

            System.out.println("Resultset Scroll --> " +  rs.getClass().getName());
            psUpdatedTimeQuery = objConnection.prepareStatement(updatedTimeQuery);
            System.out.println("Statement Noraml --> " +  psUpdatedTimeQuery.getClass().getName());
            rsUpdatedTimeQuery = psUpdatedTimeQuery.executeQuery();
            System.out.println("Column Class Name "+rsUpdatedTimeQuery.getMetaData().getColumnClassName(1));
            System.out.println("Resultset Noraml --> " +  rsUpdatedTimeQuery.getClass().getName());
            //rsMetadata = rsUpdatedTimeQuery.getMetaData();


            //NLS

            nlsstmt = objConnection.createStatement();
            nlsrs = nlsstmt.executeQuery(query);
            while (nlsrs.next())
            {
                System.out.println("NLS -->" + nlsrs.getString(1) +":::"+  nlsrs.getString(2));
            }

            if(rsUpdatedTimeQuery.next())
            {
                s = rsUpdatedTimeQuery.getTimestamp(1);
                updatedDate = rsUpdatedTimeQuery.getDate(1);
                update = rsUpdatedTimeQuery.getString(1);
                time =rsUpdatedTimeQuery.getTime(1);
                //System.out.println("Formatted Noraml date --> " + df.format(update));
            }
            if(rs.next())
            {
                System.out.println("Using Scrollable getString()" + rs.getString(1));
                //System.out.println("Formatted Scroll date --> " + df.format(rs.getString(1)));
                System.out.println("Using Scrollable date" + rs.getDate(1));
                System.out.println("Using Scrollable time" + rs.getTime(1));
                System.out.println("Using Scrollable timestamp" + rs.getTimestamp(1));
            }

            rsUpdatedTimeQuery.close();
            psUpdatedTimeQuery.close();
            objConnection.close();

            ///////Normal

            //norstmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
            norstmt = con.createStatement();

            System.out.println("Statement Normal Conn --> " +  norstmt.getClass().getName());

            norrs = norstmt.executeQuery(updatedTimeQuery);
            System.out.println("Column NormalConne Name "+norrs.getMetaData().getColumnClassName(1));
            System.out.println("ResultSet Normal Conn --> " +  norrs.getClass().getName());
            if(norrs.next())
            {
                System.out.println("Using NormalConn getString()" + norrs.getString(1));
                //System.out.println("Formatted NormalConn date --> " + df.format(norrs.getString(1)));
                System.out.println("Using NormalConn date" + norrs.getDate(1));
                System.out.println("Using NormalConn time" + norrs.getTime(1));
                System.out.println("Using NormalConn timestamp" + norrs.getTimestamp(1));
            }



        }
        catch(SQLException ex){
            ex.printStackTrace();
        }
        System.out.println("Using Normal getString() date--> "+update) ;
        System.out.println("Using Normal TimeStamp "+s.toString());
        System.out.println("Using Normal Time"+s.getTime());
        System.out.println("Using Normal date"+updatedDate.toString());
        System.out.println("Using Normal time"+time.toString());
        return s.getTime();
    }


}


The output in am getting is like


#####getLastUpdatedTime######
Statement Scroll --> weblogic.jdbc.rmi.SerialStatement
Column Scroll Class Name java.sql.Timestamp
Resultset Scroll --> weblogic.jdbc.rmi.SerialResultSet
Statement Noraml --> weblogic.jdbc.rmi.SerialPreparedStatement
Column Class Name java.sql.Timestamp
Resultset Noraml --> weblogic.jdbc.rmi.SerialResultSet
NLS -->NLS_LANGUAGE:::ENGLISH
NLS -->NLS_TERRITORY:::UNITED KINGDOM
NLS -->NLS_CURRENCY:::?
NLS -->NLS_ISO_CURRENCY:::UNITED KINGDOM
NLS -->NLS_NUMERIC_CHARACTERS:::.,
NLS -->NLS_CALENDAR:::GREGORIAN
NLS -->NLS_DATE_FORMAT:::YYYY/MM/DD HH24:MI:SS
NLS -->NLS_DATE_LANGUAGE:::ENGLISH
NLS -->NLS_SORT:::BINARY
NLS -->NLS_TIME_FORMAT:::HH24.MI.SSXFF
NLS -->NLS_TIMESTAMP_FORMAT:::DD-MON-RR HH24.MI.SSXFF
NLS -->NLS_TIME_TZ_FORMAT:::HH24.MI.SSXFF TZR
NLS -->NLS_TIMESTAMP_TZ_FORMAT:::DD-MON-RR HH24.MI.SSXFF TZR
NLS -->NLS_DUAL_CURRENCY:::?
NLS -->NLS_COMP:::BINARY
NLS -->NLS_LENGTH_SEMANTICS:::BYTE
NLS -->NLS_NCHAR_CONV_EXCP:::FALSE
Using Scrollable getString()12/22/2004 10:18:5
Using Scrollable date2004-12-22
Using Scrollable time10:18:05
Using Scrollable timestamp2004-12-22 10:18:05.0
Statement Normal Conn --> oracle.jdbc.driver.OracleStatement
Column NormalConne Name java.sql.Timestamp
ResultSet Normal Conn --> oracle.jdbc.driver.OracleResultSetImpl
Using NormalConn getString()2004-12-22 10:18:07.0
Using NormalConn date2004-12-22
Using NormalConn time10:18:07
Using NormalConn timestamp2004-12-22 10:18:07.0
Using Normal getString() date--> 2004-12-22 10:18:06.0
Using Normal TimeStamp 2004-12-22 10:18:06.0
Using Normal Time1103710686000
Using Normal date2004-12-22
Using Normal time10:18:06


Can anybody help??

regards
manoj velliyatt

 

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-12-22 at 06:41:30ID21251172
Tags

jdbc

,

oracle

Topic

Java Programming Language

Participating Experts
4
Points
0
Comments
9

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. jndi
    I am a novice in jndi. And I don't succeed in running a program. I don't really see what I have to put in Context.INITIAL_CONTEXT_FACTORY with InternetExplorer. If somebody can send me a simple example which I can use with Internet explorer, Iwould be very grateful to ...
  2. JNDI and LDAP - Problem
    Hi, I am using JNDI and LDAP to access my Exchange server. The main idea is to get the profiles of various users. I have downloaded jndi and LDAP SPI and also included the jar files in the class path. In the application, i am using INITIAL_CONTEXT_FACTORY as "com.sun...
  3. Suns J2EE Server and Oracle Thin Driver
    I am using Suns J2EE Server 1.3 and Oracle 8.1.7. I am trying to use an EJB to access Oracle DB with the Thin Driver, specified via JNDI lookup: jdbc:oracle:thin:scott/tiger@localhost:1521:orcl8 Using this URL in a standard Java program works perfect. The code inside the EJB ...
  4. JNDI
    Hi, I am trying to access Certificates stored in LDAP server using JNDI and read the pubic key and other informations. I can only get the binary values. I want to get the public key and other information in the certificate. How can i convert the binary value into X509 ce...
  5. JNDI and JBoss
    hi friend, How to configure JNDI. Well I am not having jboss.jcml on my system. Please give me proper details so that I can configure my JNDI in JBoss 4.0. thanks, Dinesh

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: bloodredsunPosted on 2004-12-22 at 07:22:54ID: 12884432

Is it anything to do with the default locale of your new setup (I use sybase not oracle so I can't be too specific). Or how the dates are being processed internally.

Failing that you might be forced to formating dates with SimpleDateFormat.

 

by: manojvelliyattPosted on 2004-12-22 at 09:21:05ID: 12885726

In both cases i am hitting the same weblogic server which has got the dfferent Classpath for different drivers.No other changes in the environment.

 

by: CEHJPosted on 2004-12-22 at 13:10:41ID: 12887617

Do we take it that your alter session statement with NLS_DATE_FORMAT had no effect?

 

by: madhurdixitPosted on 2004-12-23 at 03:21:22ID: 12891386

Just run the following query in your JDBC and get the output .

select  to_date(:1, 'YYYY-MM-DD') NewDate from dual;

Bind :1 to the date and capture NewDate in your ResultSet.

You can check out more about to_date :

http://www.adp-gmbh.ch/ora/sql/to_date.html
or
http://www.techonthenet.com/sql/between.htm

This will definitely solve your problem.

I hope you are aware of how to call this query from JDBC and stuff like that..

 

by: manojvelliyattPosted on 2004-12-23 at 05:55:15ID: 12892193

While using the thin driver is that going to take effect?
i have seen some bug rasied for the same saying it is not taking effect.
I didn't try that option.
Is this happening due to some default implementation changes inside the driver?
Scrollable resultset is returning the same result on getString() call which thrid party component displaying with latest driver. Is it happeing such a way that the default normal statement is using scrollable internally with new 9.2.0.5 drivers?

All inputs are welcome.

 

by: manojvelliyattPosted on 2004-12-23 at 07:54:54ID: 12893212

one more point , i don't have any control over the third part code to find out what is happening inside or changing anything

 

by: manojvelliyattPosted on 2005-01-04 at 09:38:13ID: 12954393

Hi all,

thanks for the help.

The below link given the answer to my problem.I thought i will share  it with all.
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#08_01

oracle.jdbc.V8Compatible=true property setting in the connection pool property will solve the issue.

thanks once again

Cheers
manoj velliyatt

 

by: PAQ_ManPosted on 2005-03-15 at 14:04:43ID: 13549536

PAQed with points refunded (500)

PAQ_Man
Community Support Moderator

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...