[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.8

oracle 9.2.0.5 thin driver problem

Asked by manojvelliyatt in Java Programming Language

Tags: jdbc, oracle

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

 
[+][-]03/15/05 02:04 PM, ID: 13549536Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Java Programming Language
Tags: jdbc, oracle
Sign Up Now!
Solution Provided By: PAQ_Man
Participating Experts: 4
Solution Grade: A
 
[+][-]12/22/04 07:22 AM, ID: 12884432Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/22/04 09:21 AM, ID: 12885726Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/22/04 01:10 PM, ID: 12887617Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/23/04 03:21 AM, ID: 12891386Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/23/04 05:55 AM, ID: 12892193Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/23/04 07:54 AM, ID: 12893212Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/04/05 09:38 AM, ID: 12954393Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/10/05 05:19 AM, ID: 13505508Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93