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.InitialContex
t;
import javax.naming.NamingExcepti
on;
import oracle.jdbc.OracleStatemen
t;
import java.text.*;
public class DateTest
{
public static void main(String args[])
{
DateTest DT = new DateTest();
}
public DateTest()
{
try
{
System.out.println("######
"+getLastU
pdatedTime
(new Hashtable())+"######");
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
private Connection getNormalConnection() {
Connection con = null;
try {
Class.forName("oracle.jdbc
.driver.Or
acleDriver
");
con = DriverManager.getConnectio
n(
"jdbc:oracle:thin:@172.26.
248.39:152
2: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.INI
TIAL_CONTE
XT_FACTORY
,
weblogic.jndi.WLInitialCon
textFactor
y.class.ge
tName());
properties.put(Context.PRO
VIDER_URL,
"t3://10.2
48.19.11:7
010");
InitialContext ctx = new InitialContext(properties)
;
DataSource ds =
(javax.sql.DataSource) javax.rmi.PortableRemoteOb
ject.narro
w(
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("#####g
etLastUpda
tedTime###
###");
//DateFormat df = DateFormat.getDateInstance
(DateForma
t.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.ge
tString(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.createStatem
ent(Result
Set.TYPE_S
CROLL_SENS
ITIVE,
ResultSet.CONCUR_READ_ONLY
);
//((OracleStatement)stmt).
defineColu
mnType(1, Types.VARCHAR);
//stmt.executeQuery("alter
session set NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
//stmt.close();
stmt = objConnection.createStatem
ent(Result
Set.TYPE_S
CROLL_SENS
ITIVE,
ResultSet.CONCUR_READ_ONLY
);
System.out.println("Statem
ent Scroll --> " + stmt.getClass().getName())
;
rs = stmt.executeQuery(updatedT
imeQuery);
System.out.println("Column
Scroll Class Name "+rs.getMetaData().getColu
mnClassNam
e(1));
System.out.println("Result
set Scroll --> " + rs.getClass().getName());
psUpdatedTimeQuery = objConnection.prepareState
ment(updat
edTimeQuer
y);
System.out.println("Statem
ent Noraml --> " + psUpdatedTimeQuery.getClas
s().getNam
e());
rsUpdatedTimeQuery = psUpdatedTimeQuery.execute
Query();
System.out.println("Column
Class Name "+rsUpdatedTimeQuery.getMe
taData().g
etColumnCl
assName(1)
);
System.out.println("Result
set Noraml --> " + rsUpdatedTimeQuery.getClas
s().getNam
e());
//rsMetadata = rsUpdatedTimeQuery.getMeta
Data();
//NLS
nlsstmt = objConnection.createStatem
ent();
nlsrs = nlsstmt.executeQuery(query
);
while (nlsrs.next())
{
System.out.println("NLS -->" + nlsrs.getString(1) +":::"+ nlsrs.getString(2));
}
if(rsUpdatedTimeQuery.next
())
{
s = rsUpdatedTimeQuery.getTime
stamp(1);
updatedDate = rsUpdatedTimeQuery.getDate
(1);
update = rsUpdatedTimeQuery.getStri
ng(1);
time =rsUpdatedTimeQuery.getTim
e(1);
//System.out.println("Form
atted Noraml date --> " + df.format(update));
}
if(rs.next())
{
System.out.println("Using Scrollable getString()" + rs.getString(1));
//System.out.println("Form
atted 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(Result
Set.TYPE_S
CROLL_SENS
ITIVE,Resu
ltSet.CONC
UR_READ_ON
LY);
norstmt = con.createStatement();
System.out.println("Statem
ent Normal Conn --> " + norstmt.getClass().getName
());
norrs = norstmt.executeQuery(updat
edTimeQuer
y);
System.out.println("Column
NormalConne Name "+norrs.getMetaData().getC
olumnClass
Name(1));
System.out.println("Result
Set Normal Conn --> " + norrs.getClass().getName()
);
if(norrs.next())
{
System.out.println("Using NormalConn getString()" + norrs.getString(1));
//System.out.println("Form
atted 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.SerialSt
atement
Column Scroll Class Name java.sql.Timestamp
Resultset Scroll --> weblogic.jdbc.rmi.SerialRe
sultSet
Statement Noraml --> weblogic.jdbc.rmi.SerialPr
eparedStat
ement
Column Class Name java.sql.Timestamp
Resultset Noraml --> weblogic.jdbc.rmi.SerialRe
sultSet
NLS -->NLS_LANGUAGE:::ENGLISH
NLS -->NLS_TERRITORY:::UNITED KINGDOM
NLS -->NLS_CURRENCY:::?
NLS -->NLS_ISO_CURRENCY:::UNIT
ED KINGDOM
NLS -->NLS_NUMERIC_CHARACTERS:
::.,
NLS -->NLS_CALENDAR:::GREGORIA
N
NLS -->NLS_DATE_FORMAT:::YYYY/
MM/DD HH24:MI:SS
NLS -->NLS_DATE_LANGUAGE:::ENG
LISH
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:::HH
24.MI.SSXF
F 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:::F
ALSE
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.OracleS
tatement
Column NormalConne Name java.sql.Timestamp
ResultSet Normal Conn --> oracle.jdbc.driver.OracleR
esultSetIm
pl
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