How to use datasources to connect to database ?
I have the following Problem
I have two identical databases, one is the development database, the other one the production database.
Now I need to find a way, how I can deploy an bc4j-application in local mode that way, that if the application is deployed to server 1 it connects to database 1 and if deployed to server 2 it connects to database 2.
JDBC connection strings do not work as the connection is deployed with the application. So the application always connects to the same database.
I thought datasources might be the solution. So I tried to define a datasource MyDS in the data-sources.xml file and specified it in the Configuration Wizard as the connection to use.
But unfortunately this does not work and i do not know why:
If I try to connect using the tester and using this datasource I get the following exception:
Level #3: javax.naming.noInitialContextException
Can anyone help me, what this means? How can I get around this using the BC4J Framework? Is there any "HowTo" Document which describes using datasources with BC4J?
Frank,
I've sorted this stuff out to some extent. Have a look at this thread:
re:? How: multiple myAppWar.ear to use OC4J's data-sources.xml pooling?
If this isn't all you need, then search on data-source.xml
and read other threads also I may have posted helps on
other threads so if you search on data-source.xml and my handle (curt504) it brings up all the threads that I posted to.
Not to say I've solved all your problems, but I solved mine anyway. :)
Good luck,
curt
Similar Messages
-
How to use JDBC to connect informix database
Dear all,
I want my client application to connect informix database by using JDBC. The JDBC driver has been installed successfully in the client computer (Win2000). The informix 5.0 resides the a Unix server named "dbserver". The following is my java program.
========================
import java.sql.*;
import java.awt.event.*;
public class Application1 {
public static void main(String[] args) {
Connection conn;
try
Class.forName("com.informix.jdbc.IfxDriver");
catch (Exception e)
System.out.println("Error "+e.getmessage());
e.printStackTrace();
return;
System.out.println("It is ok");
try
conn = DriverManager.getConnection("jdbc:informix-sqli://dbserver:1526:INFORMIXSERVER=dbserver;username=test;password=******");
catch (SQLException e)
System.out.println("ERROR ."+e.getMessage());
e.printStackTrace();
return;
System.out.println("All is fine");
===========================
However, the error appears mentioning "Attempt to connect to database server (dbserver) failed." I don't know what the problem is because my informix database server is exactly "dbserver".
Kindly need help from you guys. Thanks in advance.
KevinHi,
Plz try this (instead of 'username' use 'user') ...
DriverManager.getConnection("jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver;user=test;password=*****");
or this (pass the username and password as params)....
DriverManager.getConnection( "jdbc:informix-sqli://dbserer:1526:INFORMIXSERVER=dbserver" , "test" , "*****" );
Hope this helps
ssa.
>
I want my client application to connect informix
database by using JDBC. The JDBC driver has been
installed successfully in the client computer
(Win2000). The informix 5.0 resides the a Unix server
named "dbserver". The following is my java program.
========================
import java.sql.*;
import java.awt.event.*;
public class Application1 {
public static void main(String[] args) {
Connection conn;
try
Class.forName("com.informix.jdbc.IfxDriver");
catch (Exception e)
System.out.println("Error "+e.getmessage());
e.printStackTrace();
return;
System.out.println("It is ok");
try
conn =
onn =
DriverManager.getConnection("jdbc:informix-sqli://dbser
er:1526:INFORMIXSERVER=dbserver;username=test;password=
catch (SQLException e)
System.out.println("ERROR ."+e.getMessage());
e.printStackTrace();
return;
System.out.println("All is fine");
===========================
However, the error appears mentioning "Attempt to
connect to database server (dbserver) failed." I don't
know what the problem is because my informix database
server is exactly "dbserver".
Kindly need help from you guys. Thanks in advance.
Kevin -
How to use DataSource and External transaction in 9ias?
I'm working on a project that the application server needs to connect to over 100 databases.
I'd like to use connection pooling and external transaction service defined in OC4J's Datasources.
I wonder if anyone has an example of using datasource and external transaction service for OC4J.
Right now, I export toplink project to a java source and do the initialization there manually but I don't know how to use Datasource to get connections and how to use the external transaction service in the java code for OC4J.
I really appreciate you help.
WeiHere is a fill in the blank example on how you could set this up through code:
Project project = new MyProject();
// alternatively, use the XMLProjectReader
server = project.createServerSession();
server.getLogin().useExternalConnectionPooling();
server.getLogin().setConnector(new JNDIConnector(new javax.naming.InitialContext(), "jdbc/DataSourceName"));
// the next line depends on the type of driver you want to use.
server.getLogin().useOracleThinJDBCDriver();
server.getLogin().useOracle();
server.getLogin().setUserName("username");
server.getLogin().setPassword("password");
server.getLogin().useExternalTransactionController();
server.setExternalTransactionController(new Oracle9iJTSExternalTransactionController());
server.logMessages();
server.login(); -
How to use taglibs in JSP for Database access
Hi
Could any one please tell me how to use taglibs in JSP for Database access
with regrds
JojoThis is a sample how to connect to a MySQL database with JSTL 1.0:
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>JSTL MySQL</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<c:catch var="e">
<sql:setDataSource var="datasource" url="jdbc:mysql://Your_Server_Name_Here/You_Schema_Here"
user="Your_Username_Here" password="Your_Password_Here"
driver="com.mysql.jdbc.Driver"/>
<c:out value="datasource= ${datasource}, Class = ${driver.class}"/>
<br />
<br />
<sql:query var="deejays" dataSource="${datasource}">SELECT * FROM Your_Table_Name_Here</sql:query>
<table>
<%-- Get the column names for the header of the table --%>
<c:forEach var="columnName" items="${deejays.columnNames}"><th><c:out value="${columnName}"/></th></c:forEach>
<tbody>
<%-- Get the value of each column while iterating over rows --%>
<c:forEach var="row" items="${deejays.rows}">
<tr><c:forEach var="column" items="${row}">
<td><c:out value="${column.value}"/></td>
</c:forEach>
</tr>
</c:forEach>
</tbody>
</table>
</c:catch>
<br />
<br />
<c:if test="${e!=null}"><span class="error">Error</span>�
<c:out value="${e}" />
</c:if>
</body>
</html>And this thread might help you:
http://forum.java.sun.com/thread.jspa?threadID=639471&tstart=44 -
How do i configure DSN connection to database Programmatically
Hi to all,
Can anybody assist me as how could i configure DSN connection to database Programmatically.
Thanks in advance.
Regards
khiz_engHi DrClap,
Many thanx for your advise, i have also done with MS-Access but now i wnated to have with .csv value, how i am going to have this .I have searched the whole JDBC forum already unable to find for .csv
Please provide me and solve my problem
Thanks in advance.
khiz_eng -
How to used the internet connection adsl on my com...
how to used the internet connection adsl on my computer by nokia n73 me
i whant used the adsl connection in nokia n73 me by Bluetooth or cable
and thank youHi Theo,
There are several ways to implement this using simple timing features of LabVIEW. Two fairly simple methods are comparing system time stamps or using the Wait VI provided in the Timing palette. The time stamp comparison requires a little bit more programming, but can be included in your main program loop. To use the Wait function, you will probably need to construct a new loop parallel to your main loop. I have attached screenshots of these two implementations. Please let me know if you have any more questions.
Donovan
Attachments:
WaitDelay[1].Png 5 KB
TimeStampFalse.Png 11 KB
TimeStampTrue.Png 11 KB -
HT201205 how to use bluetooth to connect iphone to ipad???
how to use bluetooth to connect iphone to ipad???
what you do you expect them to be able to do with eachother ?
you can transfer files or data between them unless you find some 3th party program which does that
this is what ios devices support in terms of bluetooth profiles
http://support.apple.com/kb/ht3647
this is the full list of all bluetooth profiles (even your computer only support a fragtion of the list)
http://en.wikipedia.org/wiki/Bluetooth -
How to use JDBC to connect Tomcat with database server?(Urgent!)
I try to deploy the tomcat and make it connect with databaser server.
I am using mysql connector J 3.0. I added the CLASSPATH of mysql-connector-java-3.0.7-stable-bin.jar in the tomcat.sh .
I also add the web application in server.xml.
When I start tomcat, I can see using Classpath including mysql-connector-java-3.0.7-stable-bin.jar .
But when i browse my jsp including the jdbc, wait for a while, I get a message as following: Timeout on server localhost. My web server and database server is same computer.
Could you tell me what's wrong?Did you check to see that the MySQL database was indeed up and running, and accepting connections when you started Tomcat? Did you make sure that your firewall permits connections to the database?
Timeout errors generally occur when you send a request to a server and the server does nothing with it - i.e., it doesn't respond to it in any way. Most firewalls are configured this way. If I telnet to your machine and I get "connection refused", I know your machine exists and I can try hacking into it. If I telnet and get nothing at all, then I will either assume either there's no actual machine at that address or it's unresponsive. -
When is it appropriate to use DataSource (or Connection pooling)?
Hello all,
I'm having some design issues with my application and I'm starting to think that maybe using Connection pooling is not suited for my application. I'm using Tomcat 5.5.12 if it's any relevant..
The architecture of our application looks like this:
Servlets -> App Helper classes -> DB/Accessor classes
looks like the three-tier architecture described in this document: http://www.subrahmanyam.com/articles/servlets/ServletIssues.html
I have read on the Tomcat docs that said that using DataSource is good practice and improves efficiency since it recycles database connections. However, if the accessor/DB classes are not servlets, how can I use the DataSource facility that interacts with Tomcat?
I would like to know whether it is a good idea to use DataSource in my case and if so, how? (since they are not servlets)
Thanks in advance :)Hi. Thank you for replying.
In the examples that I've seen that use JNDI for Database access, it seems that DataSource is always used--in other words, JNDI and DataSource always seem to be used together (in Servlets). I have not found a case where JNDI is used by itself to access the Database--perhaps I'm not looking in the right place. Could you point me to some documentation maybe?
Thanks a lot! -
Where can I find how to use DataSource?
Hi,
I am quite new to JDBC and is writing some small database program. I find many examples use DataSource, I want to know how to use it, but cannot find the API in the docs section of java.com.
Can anyone point me to the location of javax.sql.DataSource, or even better some examples of using DataSource?
Also, I am using Oracle as my database, do I need to register the oracle driver first for DataSource first also?
Any help will be approcaited.Hi,
You can get the more detailed documentation at
http://java.sun.com/j2se/1.4/docs/api/javax/sql/DataSource.html and please visit http://www.datadirect-technologies.com/download/docs/jdbc/jdbcref/usejdbc.htm for information on how to connect to database using datasources.
Hope this helps.
With Regards
Gayam_Slash -
How to read the RD Connect Broker DataBase!!!!
The msdn say there is a RD Connect Broker Data Base , it store the session information,but i dont know where is it and how to read it !
Thank you !!!!Hi,
You can use the vbs script below to dump the contents of the RD Connection Broker database.
With credits to the authors of the Windows Server 2008 R2 RDS Resource Kit for putting it in there!
' Copyright (c) 2004-2005 Microsoft Corporation
' WMI Script - SDDatabaseDump.vbs
' Author - GopiV
' This script dumps the contents (clusters and associated sessions)
' of the Session Directory database
' USAGE: Cscript.exe SDDatabaseDump.vbs <SBservername> <Administrator> <Password>
const TAB = " "
const LINESEPARATOR = "------------------------------------------------"
ON ERROR RESUME NEXT
'* Function blnConnect()
'* Purpose: Connects to machine strServer.
'* Input: strServer a machine name
'* strNameSpace a namespace
'* strUserName name of the current user
'* strPassword password of the current user
'* Output: objService is returned as a service object.
Function blnConnect(objService, strServer, strNameSpace, strUserName, strPassword)
ON ERROR RESUME NEXT
Dim objLocator
blnConnect = True 'There is no error.
' Create Locator object to connect to remote CIM object manager
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
if Err.Number then
Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred in creating a locator object."
if Err.Description <> "" then
Wscript.Echo "Error description: " & Err.Description & "."
end if
Err.Clear
blnConnect = False 'An error occurred
Exit Function
end if
' Connect to the namespace which is either local or remote
Set objService = objLocator.ConnectServer (strServer, strNameSpace, strUserName, strPassword)
if Err.Number then
Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred in connecting to server " _
& strServer & "."
if Err.Description <> "" then
Wscript.Echo "Error description: " & Err.Description & "."
end if
Err.Clear
blnConnect = False 'An error occurred
end if
objService.Security_.impersonationlevel = 3
if Err.Number then
Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred in setting impersonation level " _
& strServer & "."
if Err.Description <> "" then
Wscript.Echo "Error description: " & Err.Description & "."
end if
Err.Clear
blnConnect = False 'An error occurred
end if
end Function
' Start of script
if Wscript.arguments.count<3 then
Wscript.echo "Script can't run without 3 arguments: ServerName Domain\UserName Password "
Wscript.quit
end if
Dim strServer, strUserName, strPassword
Dim objService, blnResult
' Extract the command line arguments
strServer=Wscript.arguments.Item(0)
strUserName=Wscript.arguments.Item(1)
strPassword=Wscript.arguments.Item(2)
' Connect to the WMI service on the SD Server machine
blnResult = blnConnect( objService, strServer, "root/cimv2", strUserName, strPassword )
if not blnResult then
Wscript.echo "Can not connect to the server " & strServer & " with the given credentials."
WScript.Quit
end if
Set clusterEnumerator = objService.InstancesOf ("Win32_SessionDirectoryCluster")
if Err.Number then
Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred"
end if
if clusterEnumerator.Count = 0 then
Wscript.Echo "No clusters found in Session Directory database on " & strServer & "."
Wscript.Echo
Wscript.Quit
end if
for each clusterObj in clusterEnumerator
WScript.Echo LINESEPARATOR
WScript.Echo "ClusterName = " & clusterObj.ClusterName
WScript.Echo "NumberOfServers = " & clusterObj.NumberOfServers
WScript.Echo "SingleSessionMode = " & clusterObj.SingleSessionMode
Wscript.Echo
set serverEnumerator = objService.ExecQuery("Select * from Win32_SessionDirectoryServer where ClusterName = '" & clusterObj.ClusterName & "'")
if Err.Number then
Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred"
end if
if serverEnumerator.Count = 0 then
Wscript.Echo "Error : No servers in cluster " & clusterObj.ClusterName
Wscript.Echo
else
' Enumerate the servers in this cluster
for each serverObj in serverEnumerator
WScript.Echo TAB & "SERVER :"
WScript.Echo TAB & "ServerName = " & serverObj.ServerName & " ServerSingleSessionMode = " & serverObj.SingleSessionMode & " LoadIndicator = " & serverObj.LoadIndicator
' WScript.Echo TAB & "ServerIP = " & serverObj.ServerIPAddress
' WScript.Echo TAB & "ServerWeight = " & serverObj.ServerWeight
set sessionEnumerator = objService.ExecQuery("Select * from Win32_SessionDirectorySession where ServerName = '" & serverObj.ServerName & "'")
if Err.Number then
Wscript.Echo "Error 0x" & CStr(Hex(Err.Number)) & " occurred"
end if
if sessionEnumerator.Count = 0 then
WScript.Echo
WScript.Echo TAB & "No sessions on server " & serverObj.ServerName
WScript.Echo
else
WScript.Echo TAB & "NumberOfSessions = " & sessionEnumerator.Count
Wscript.Echo
' Enumerate the sessions on this server
for each sessionObj in sessionEnumerator
WScript.Echo TAB & TAB & "SESSION :"
WScript.Echo TAB & TAB & "UserName= " & sessionObj.DomainName & "\" & sessionObj.UserName & TAB & "ApplicationType= " & sessionObj.ApplicationType
& TAB & "SessionState= " & sessionObj.SessionState
WScript.Echo TAB & TAB & "CreateTime= " & sessionObj.CreateTime & TAB & "DisconnectTime= " & sessionObj.DisconnectTime
' WScript.Echo TAB & TAB & "ServerName= " & sessionObj.ServerName
' WScript.Echo TAB & TAB & "SessionID= " & sessionObj.SessionID
' WScript.Echo TAB & TAB & "ServerIP= " & sessionObj.ServerIPAddress
' WScript.Echo TAB & TAB & "TSProtocol= " & sessionObj.TSProtocol
' WScript.Echo TAB & TAB & "ResolutionWidth= " & sessionObj.ResolutionWidth
' WScript.Echo TAB & TAB & "ResolutionHeight= " & sessionObj.ResolutionHeight
' WScript.Echo TAB & TAB & "ColorDepth= " & sessionObj.ColorDepth
' WScript.Echo
WScript.Echo
next
end if ' End of sessions on this server
next
end if ' End of servers on this cluster
next
Wscript.Echo
Wscript.Echo
Wscript.Echo "Dump of SD database on " & strServer & " complete."
Kind regards,
Freek Berson
http://www.microsoftplatform.blogspot.com
Wortell company website -
How to i get the connect to database with OLAP API 9.2.0.0
hi all,
when i use the OLAP API (9.2.0..0) to connect the database,i gained the message of the following:
java.lang.NoClassDefFoundError: com/sun/java/util/collections/HashMap
void oracle.express.olapi.transaction.ExpressTransactionProvider.<init>() ExpressTransactionProvider.java:40
void mypackage3.APPEX.init()
APPEX.java:51
void sun.applet.AppletPanel.run()
AppletPanel.java:344
void java.lang.Thread.run()
Thread.java:484
JDev=9.0.3
OLAP API=9.2.0.0
Oracle 9i 9.2.0.1
and how can i get the OLAP API 9.2.0.4.1?
anyone can help me !
thanks!!!Hi, yes, there are at least two known ways:
1. if you happen to have a UCCX premium, you can create an HTTP application that serves up the prompt file,
2. you can try to access the prompt file like this: http://<uccxip>:9080/prompts/dirname/promptfilename.wav
G. -
How to use jdbc to connect oracle
I want use jdbc direct to connect oracle database,and I
want to use sun Company or oracle Company driver. how can I get driver and how do I write connection string?
Deeply to wait your reply,thank you!The correct format would be jdbc:oracle:thin@server:port:sidTry "jdbc:oracle:thin:@192.168.84.20:1521:ORDB","ysys","fareast"and see what happens.
Note that you two formats for the DriverManager.getConnection() method; if DriverManager.getConnection(db_url, username, password) doesn't work, try the other call with a fully-qualified database url:DriverManager.getConnection("jdbc:oracle:thin:ysys/[email protected]:1521:ORDB")The SID is the server ID that was given to the instance when the database was installed; default is ORCL, but may have been changed. Port default is 1521, but again, this may be different for your system. -
How to use the current connection when calling db procedure ?
dear all,
Am using Jdevleoper 11.1.1.3 ,
I have a java class that call a database procedure , now everything is going fine with me but a bit slow bcoz am openning a new connection I think it would be definitely faster if am using the current connection
so how can i re-write my code so i can use the current connection istead of defining a new connection to the DB :
public void DeleteApp (int PAppNo){
String username,password,thinConn;
username = "ACC";
password = "ACC";
thinConn = "jdbc:oracle:thin:@..."
try {
DriverManager.registerDriver(new OracleDriver());
Connection conn = DriverManager.getConnection(thinConn, username, password);
CallableStatement cs = conn.prepareCall(" { call myprocedure(?,?,?) } ");
cs.setInt(1,PAppNo);
Thanks for all,
LamaDelta,
You shound NOT be doing JDBC calls from your UI project. You should put the code as a service method in your application module, expose the service method to the client, and then call it through the binding layer from your UI http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcservices.htm#sm0212
thx John & timo but u always post the same reply at the same time for my questionsTimo and I have been around long enough that we recognize the questions that have been posted 9,461,293,811 times before and know the stock answers, and know where in the documentation the answers are given. As you appear to be new to ADF, I'd strongly recommend reading the Fusion Developer's Guide (skim it once and then read in detail the parts that interest you). As I've said before, so many of the basic (and not-so-basic) concepts are covered in there. Once you've skimmed it in enough detail, then the next time you have a problem, you might not know the answer, but you'll remember, "ah, I think I read something about that before, let me check..."
John -
What protocol do i use to direct connect my DATABASE? instead of TCP/IP
I read there's a protocol (or commmand or something) to directly connect my DATABASE (in a stand alone computer).
how do i do that?
because Since I have no network card installed in my computer and since i have a DHCP ADSL connection (thru usb modem), i cannot connect my DATABASE (ORACLE 9.2) and Developer 6I (both in my computer). WINDOWS XP (SP2).
is there something to fix that?
also when i start my LISTENER as soon as i connect thru sqlplus or make 1 test with TNSPING it crashes. :(
is that because I dont have a fixed IP?
i 've tried using 127.0.0.1 my Internet's IP, my host, LOCALHOST, and nothing fixes it.
HELPHi,
Try using IPC. for example something like this:
tnsnames.ora
TESTDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = testdb)
Listener.ora would have something like this:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
you may also have to change your init.ora if there are references to MTS/SHARED SERVER stuff.
cheers,
john
Maybe you are looking for
-
HT204053 Can my children and I use the same apple ID with different iPhone iPad and iPod ?
I am having trouble with my new iPhone 5 address book and some updates on the apps store There's some old apple ID that is showing up. I don't even remember this email address What can I do to adjust all this Thanks
-
Flash CC publish to Nexus 4 doesn't work
Hi all, I'm a newbie when it comes to mobile development, but I have a lot of experience with AIR for desktop. I have a Google Nexus 4 and cannot get Flash CC to publish to it for a simple test. First I found that Flash CC couldn't find the device at
-
TV/DVD 22DL833B combo is playing DVD in black and white
We were given a year old, but never used Toshiba 22DL833B tv and dvd all in one. On playing a DVD, the picture is black and white. As far as we are aware, there is no physical fault. We are unable to check if it is just the dvd player that is affecte
-
CUA- Deleting user IDs from Child systems
Is there a possibility of configuring CUA in such a way that user IDs can be created and access can be updated from CUA but deleting user IDs should be taking place only in the child system (Not in all the child systems)?
-
Planning & HFM Certifications - Advice Appreciated
Hello All – For those on the board that are certified Hyperion professionals (Planning and HFM). I'd really appreciate your input as to the value of these certifications both from the perspective of 1) Getting onto projects 2) Being able to perform o