Getting the Database Timezone
Hi,
I am trying to retrieve the database time zone using JDBC. I retrieved the database time using "select sysdate from dual"
When I try to get the time zone from this date it gives me my current timezone as opposed to the database time zone( when the database is in a different timezone ).
This happens with all the drivers I use ( 8i drivers with 8i database and 9i drivers with 9i database )
Any pointers? Am I using the wrong call to get the database time? Is there an Oracle specific call that can be used?
Here is the code ..
String stmtStr = "Select sysdate from dual";
java.sql.PreparedStatement stmt =
conn.prepareStatement( stmtStr );
ResultSet rset = stmt.executeQuery( );
while( rset.next() )
Timestamp ts = rset.getTimestamp( 1 );
System.out.println( "JDBC Database Time :" + ts );
SimpleDateFormat sdf =
new SimpleDateFormat( "dd.MM.yyyy H:mm:ss zzz" );
System.out.println( sdf.format( ts ) );
Hi Shailesh,
Basically you need to get the default time zone from the Oracle database embedded JVM and set it as the time zone for the "SimpleDateFormat" class. If you look at the source code for the "SimpleDateFormat" class, you will see that it contains an instance member which is an instance of class "java.util.Calendar". If you look at the source code for "Calendar", you will see that it contains a member which is an instance of a class that extends "java.util.TimeZone". The "TimeZone" in "SimpleDateFormat" comes from the JVM it is running in -- so it is different to the JVM running inside the Oracle database (according to the information you have posted).
Please check the source code to verify the above.
Hope this has helped you.
Good Luck,
Avi.
Similar Messages
-
Error while applying a patch "Unable to get the database connection"
Dear Experts,
A patch which got successfully applied is failing Production and the error is kind of surprising to me.
Apps version is 11.5.10.2
db version is 10.2.0.4
The worker log file shows
Time when worker restarted job: Thu Nov 24 2011 22:14:52
Start time for file is: Thu Nov 24 2011 22:14:52
adjava -ms128m -mx256m -nojit oracle.apps.fnd.odf2.FndXdfCmp &un_apps &pw_apps &un_apps &pw_apps &jdbc_protocol &jdbc_db_addr table &fullpath_pa_patch/115
Reading product information from file...
Reading language and territory information from file...
Reading language information from applUS.txt ...
Temporarily resetting CLASSPATH to:
"/erp/oracle/prodappl/ad/11.5.0/java/adjri.zip:/usr/java14/jre/lib/charsets.jar:/usr/java14/jre/lib/core.jar:/usr/java14/jre/lib/graphics.jar:/usr/java1
Calling /usr/java14/bin/java ...
Exception occured
Copyright (c) 2003 Oracle Corporation
Redwood Shores, California, USA
XDF(XML Object Description File) Comparison Utility
Version 1
NOTE: You may not use this utility for custom development
unless you have written permission from Oracle Corporation.
Unable to get the database connection using schema username/passwordIo exception: The Network Adapter could not establish the connection
AD Run Java Command is complete.
Copyright (c) 2002 Oracle Corporation
Redwood Shores, California, USA
AD Java
Version 11.5.0
NOTE: You may not use this utility for custom development
unless you have written permission from Oracle Corporation.
AD Worker error:
The above program failed. See the error messages listed
above, if any, or see the log and output files for the program.
Time when worker failed: Thu Nov 24 2011 22:14:53
{code}
The error says database connection error. I am able to connect to the database using sqlplus. I tried to restart the failed worker, but the same error is repeating.
Any help would be appreciated.
Thanks
qARS
Edited by: user7640966 on Nov 24, 2011 9:07 AMHussein,
One thing which I noticed now is in the apps Tier the
tnsnames.ora under $TNS_ADMIN
shows entry like this:
PROD=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=<appsServerName>)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=<dbServer>)(PORT=1521))
(CONNECT_DATA=
(SID=PROD)
)Actually *(ADDRESS=(PROTOCOL=tcp)(HOST=<appsIPaddress>)(PORT=1521))* this line in the tnsnames.ora is not correct. In fact the appsServerName should be replaced with dbServerName
I deleted the tnsnames.ora and reran autoconfig but it is again recreating the same entry.
Any clue how this can be fixed?
Thanks
qARS -
Problem in getting the database connection from a connection pool
Hai All,
I am facing a problem in getting the database connection from a connection pool created on weblogic server 8.1.
I am using the Oracle database 8.1.7.
I have configured my connection pool, datasource and JNDI in weblogic.
In my java program i have the following code to retrieve the connection.
import java.sql.*;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
class jdbcshp1 {
public static void main(String[] args) {
Connection connection = null;
try {
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); // Wanna get rid of this.
ht.put(Context.PROVIDER_URL,"t3://localhost:7001"); // wanna get rid of this.
// Get a context for the JNDI look up
Context ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("myjndi1");
//Create a connection object
connection = ds.getConnection();
The above code is working fine but, the two ht.put statements are creating problem.
The problem is, after converting the application into WAR file it can be deployed
on any machine or different port on same machine. My application fails if its deployed on
weglogicserver which is at different port.
Is there any way that i can get rid of those ht.put statements or any other way to solve the problem.
any help is appreciated.
Thanks in advance
Pooja.Hai All,
Firstly, thanks for ur reply.
Even i have seen some code which uses context constructor with out any parameter and works fine.
i dont understand why its not working for my code.
When i remove those ht.put code and use context constructor with out any parameter, it giving an error.
Context ctx = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("ocjndi");
connection = ds.getConnection();The error is as follows:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
the above error is forcing me to include those code but if the port number is changed the code will not work. Plz let meknow if some setting have to be made.
I appreciate all ur valuable help.
Thanks once again.
Pooja. -
How to get the Database type from weblogic Db connection
I want to use database version control in my application . that means different database type use different Sql Statement. Such as in weblogic7.0 if I create SqlServer JDBC pool then I will use some special Sqlserver sql Statement . such as some join statement. If I create Oralce JDBC pool then I have to use different Sql statement . because these two database support different Sql statement.
What my question is how to get the database type from the connection.For a normal jdbc driver you can use
Connection.getMetaData()
To get the meta data, in particular the getDatabase...() methods.
That might or might not work.
However, at the very least in the server you have access to the weblogic properties so you can parse the pool property to figure it out. -
How to get the database owner name in T-SQL script
Hello, All!
I want to get the database ower name (in format DOMAIN\user) by through T-SQL script. But SELECT * FROM sys.databases returns only owner_sid.
Please show me a way - how to get the owner name, if you have only owner_sid. Or, may be, somebody know another way ?
Andy MishechkinSELECT suser_sname( owner_sid ), * FROM sys.databases
http://www.t-sql.ru -
Java didn't get the correct timezone
Hi,
i have problem with java getting the correct timezone. This problem make me another problem with Oracle who use Java by Enterprise Manager.
The OS System has the right timezone.
if i run this w32tm /tz on command, i get
Time zone: Current:TIME_ZONE_ID_DAYLIGHT Bias: 180min (UTC=LocalTime+Bias)
[Standard Name:"Argentina Standard Time" Bias:0min Date:(M:3 D:2 DoW:6)]
[Daylight Name:"Argentina Daylight Time" Bias:-60min Date:(M:10 D:3 DoW:6)]
But if i create a java file with this procedure
import java.util.*;
public class DefaultTimezone
public static void main(String[] args)
TimeZone def = SimpleTimeZone.getDefault();
String id = def.getID();
System.out.println("default time zone: " + id);
i run java DefaultTimezone
i get
default time zone: America/Rio_Branco
So, After this i have donwloaded the program tzupdater to fix it
but this didn't fix anything. The update it's right too.
Please, Help.!!
Thanks.Yo no say.
I don't know.
How close to Brazil do you live? -
Getting the database dump based on constants
Hi,
I am having a ploblem in my project. The ploblem is i have to get the database dump based on diffrent constants that is if i have taken the dump yesterday and after that some modefaction has bean done tin the database now i want to take the database dump only for the modifyed data but not for the whole data. How can i get the database dump in this mannerUnfortunately, this is not a feature of the Oracle Migration Workbench. It has been designed as a one shot recovery vehicle for the 3rd party database. I understand why you want to do this and it is on our list of enhancements.
I'm sorry for the inconvenience
Barry -
What is the view to get the database type using oem grid
Currently i have oem grid 11g , and i want to query a view where i can get the database type like (standalone, cluster database type).
In OEM we have search option as database/cluster/clusterdatabase.....so for this type i want to check in database level in repository.Please provide me the view with in the grid repository.Some handy views can be found here:
http://docs.oracle.com/cd/E11857_01/em.111/e12135/views.htm#BACCFCAB
SQL> select target_type, count(*) from MGMT$TARGET group by target_type;
TARGET_TYPE COUNT(*)
osm_cluster 3
oracle_listener 36
oracle_exa_cisco_switch 2
oracle_exa_kvm 2
oracle_home 68
has 12
rac_database 3
weblogic_j2eeserver 2
oracle_apache 1
oracle_ias_farm 1
oracle_exa_pdu 2
oracle_oms 1
cluster 3
oracle_exadata_grid 3
oracle_exa_ilom 12
oracle_exadata_dbsys 3
oracle_oms_console 1
j2ee_application 3
metadata_repository 2
oracle_apm 1
oracle_exadata 21
oracle_ibswitch 5
oracle_dbmachine 3
oracle_ibnetwork 2
oracle_beacon 1
oracle_oms_pbs 1
oracle_em_service 2
oracle_dbsys 18
oracle_emd 25
osm_instance 12
oracle_database 27
host 25
weblogic_domain 1
oracle_emrep 1
34 rows selected.Good luck. -
Not able to get the database data into the Tree Control
Hi Everybody,
I have to populate the tree control with nodes and items, which is to be populated from the database, and the tree control is <b>dynamic</b>. I mean, there is a <b>toolbar</b>, whenever a <b>pushbutton is clicked</b>, depending on that the tree contents has to be changed.
If anybody had worked with <b>CL_GUI_COLUMN_TREE</b> control to get the data from database, depending upon the <b>pushbutton selected in Toolbar</b>, please paste the seudocode for it.
Regards,
Abdul,
Intelligroup.
P.S: Helpful answers will be rewarded.have you seen this demo program
SAPCOLUMN_TREE_CONTROL_DEMO
Regards
Raja -
URGENT: how to get the database error message into application?
Hi, pls give some idea:
For example, the database is MS Access. When insertion failed, the getMessage() method of SQLException will print "General error", while the log file created by ODBC will be "[MICROSOFT][ODBC DRIVER]column ID no found in student table"(...just a example).
So, how to get this message in our application?instead of using the getMessage method, have you tried something like this:
try {
} catch (Throwable t1) {
System.out.println(t1.toString());
}If that still doesn't work, you can always redirect the log entries into a textarea but then everything that appears in the log file will be redirected!
;o)
V.V. -
How to get the database size of several system
Hi
We've got a lot of database system on our landscape. I want to make a simple report to get the size the all our database on a weekly base.
I try to get a RZ20 value on it without succes.
Do you know a sql request that i could launch on all my database to get this information ? i did'nt find any V$^view with this information.
thanks for your help
florent"The database size" can be
- the total size
- the filled size
- the filled size without undo/temp
You can use DBACOCKPIT to centrally manage multiple instance and check the sizes.
Markus -
How to get the Database Type quan in my internal table?
Hi, I have the following problem, I have a Database Table with a column foo (QUAN with length 15 and 3 dec). Now I want to read this field into a Internal Table and the corrospoding field is:
foo(19) TYPE C,
But this is not working I'm getting the dump:
DBIF_RSQL_INVALID_RSQL
CX_SY_OPEN_SQL_DB
What is the correct abap type in my structure to put this QUAN in my internal table?Hi Michael,
when you know your data base field name then u can define your variable f00 of your db field type like
foo type <dbtabname>-<fieldname) -----ex -- j_1iexcdtl-menge
or define foo as packed no
data : foo(19) type p decimals 3.
Regards -
What is the Table/View name for getting the Database Object Dependencies
I am running the Database Object Dependencies report to get the reference of Database Object and their respective Application Component.
Applications xxxx -> Application Reports -> Shared Components -> Database Object Dependencies -> Compute Dependencies
I want to develop a report for the same purpose, Just want to know what is the APEX Tables / Views they are using to run this report, so that I can use the same Tables to create my own report.
Thanks,
DeepakHi Andy,
when I am using the following query...I am not getting any result...
select name, type, owner
from all_dependencies
where referenced_owner = 'APEX_030200'
and referenced_name = 'WWV_FLOW_PATCHES'
AND OWNER= 'XXXXXXX' --- (addeed this to the where clause)
I modified the query.....I am getting the result.....
select name, type, owner
from all_dependencies
AND OWNER= 'XXXXXXX'
- But I am not getting which database object(table/view) is using which Application Page/Component like we have in Database Object Dependencies.
- Also what is this REFERENCE OWNER & REFERENCE_NAME ----
referenced_owner = 'APEX_030200'
and referenced_name = 'WWV_FLOW_PATCHES'
I am little bit confused, Can you pl expalin me in details......
Thanks,
Deepak -
How to get the Database Driver list
Hi... I want to know that particular database driver is registered or not in windows.. how can i get this info.
And I want to get the list of all the database drivers registered in windows..
Can anybody help me..dcminter wrote:
Well, seeing as how none of them are registered, until your program registers them, simply keep a list.That's not actually true. If the JAR is in the classpath then a JDBC4 driver will use the service provider hooks to register itself.
When first loaded. Which is unlikely to happen until you explicitly load it.
Being on the classpath doesn't mean the JVM will actually do anything with a class. Either an application will have to initiate some action or it will have to be initiated by the manifest of the jar (and I'm not sure that will actually do anything until a class from that jar is actually required to be loaded). -
How to get the Database table behind condition records
Hello All
In transaction VK13, after giving condition type, I can select sales document.
For a given Sales Document number, there are several conditions.
How can i extract all the conditions for a given sales document?
I am coding a report for this. In which database table can i get the condition between sales document number & different conditions attached to it?
On the screen, i can see that the fields are from the structure KOMG. What is the corresponding table?
Thanks
Chandra SekharHi,
corersponding tables will be konp , a771,a511,a564
here i am providing you sample query related to it
{ -Get the Territory list price YPR0
SELECT vkorgau
zzland1_ag
zzmatgrade
a511~kfrst
datbi
datab
kbetr
INTO TABLE it_list1
FROM a511
JOIN konp
ON a511knumh = konpknumh
WHERE a511~kappl = 'V'
AND a511~kschl = 'YPR0'
AND vkorgau = '5000'
AND zzland1_ag = v_land1
AND loevm_ko <> 'X'.}
Thanks & Regards,
Sateesh.
Edited by: sateesh kumar on Nov 12, 2009 12:59 PM
Maybe you are looking for
-
How to send a file as an attachment using mailx
Hi Can any one tel me how to send a file as an attachment using mailx command in shell script. Thanks, Suman.
-
Using table with no primary key
I habe some older table that use unique indexes (instead of primary keys). Some of these are comprised of 3 or 4 columns (see below). When I try to create an HTML DB tabular form or report is it asking for primary key. How do I get around this? CREAT
-
Link to one keynote document from another
Hi there, like many designers, I use Keynote for doing mobile/web design & prototyping. While never meant for this, it's actually one of the fastest tools out there. One of the things that is limiting though, is that you for sane reasons only can hav
-
Class not found javax.swing.JLabel
Hello, I'm using JDK 1.3.0 and now I tried the first time to include Swing components into my Applet. When I compile the coding there are no errors and even when I use a standard coding example I always get the "class not found error message" for the
-
Apple Mail produces illegal html
We've had all kinds of problems with Mac-generated emails coming up blank for some recipients. Our service provider did a detailed analysis and discovered that the Apple mail application (version 2.1 - 752/752.2) generates illegal html!!!! Here is an