Connecting to database code
I'm looking for some code that will connect to a MS-SQL DB ( or any other DB ), query it and work with a result set. It doesn't have to be too specific in what it does, I'm just looking for some generic code that I can learn from.
Thanks,
try http://www.google.co.uk/search?q=jdbc+tutorial => 1.4 million hits
Similar Messages
-
Code to connect to database in Webdynpro-- iviews
Hi All-
Could you let me know the code to connect to database
in WebDynPro-->iviews.
Regards,
CrisHi,
Here are the two ways of connecting to a database through coding:
////1////
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
java.sql.Connection conn= java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://<IP>:<port>;user=<abc>;password=<xyz>;database=<DB name>");
////2////
InitialContext initialContext = new InitialContext();
DataSource dataSource = (DataSource)initialContext.lookup("jdbc/SRI");
java.sql.Connection conn = dataSource.getConnection();
Regards
Srinivasan T -
Sample code for connect to database
Hi
like to know if there is any sample code for me to follow through to connect to database using ODBC.
I am currently writing a program in visual c++.
like to know how to connect database to store image in the database
using visual c++ code.....
hope that is not too difficult.in JSTL pratical guide for JSP programmers by Sue Spielman
<sql:setDataSource var="datasource"
driver="org.gjt.mm.mysql.driver"
url="jdbc:mysql://localhost/db"
user="guest"
password="guest" />
<sql:query datasource="${datasource}...
<html>
<head>
<title>
Display Results
</title>
</head>
<body>
<c:catch var="sqlError">
<sql:query var="bookList" dataSource="${datasource}">
SELECT * FROM books WHERE title LIKE 'J%' ORDER BY author
</sql:query>
</c:catch>
<c:if test="${not empty sqlError}" >
Make sure you have already run the databaseinit.jsp file
</c:if>
<h2>Listing all books that start with a 'J', ordered by author</h2>
<br>
<table>
<th>Title</th>
<th>Author</th>
<c:forEach var="book" items="${bookList.rows}">
<tr>
<td><c:out value="${book.title}" /></td>
<td><c:out value="${book.author}" /></td>
</tr>
</c:forEach>
</table>
</table>
<h2>Show using choose/when/otherwise conditional to display results</h2>
<table>
<tr><th>Title</th></tr>
<c:forEach var="book" varStatus="current" items="${bookList.rows}">
<tr>
<c:choose>
<c:when test="${current.first}" >
<td><font color="#0000FF"><c:out value="${book.title}"/></font></td>
</c:when>
<c:when test="${current.count % 2 == 1 }" >
<td><font color="#FF0000"><c:out value="${book.title}"/></font></td>
</c:when>
<c:otherwise>
<td><c:out value="${book.title}"/></td>
</c:otherwise>
</c:choose>
</tr>
</c:forEach>
</table>
</body>
</html> -
MySQL Database Connection (two databases at the same time)
I have never had to open more than one MySQL database from within the same website before, but I do now. The website I have is designed where all the content comes from within the main database. I am building an Inventory system that I want within it's own database, in the event I would ever need to move the application to another server or something, I don't want this data residing in the main database.
Currently, I open the database connection from within a file called "common.php" that resides in a directory called "lib" that can be accessed from the root directory. Below is the proposed code that would be placed within the "common.php" file:
// Define Database Variables
$dbserver = "127.0.0.1";
$dbuser = array('clevelan_user1', 'clevelan_user2');
$dbpass = array('P@ssw0rd', 'P@ssw0rd2');
$dbname = array('clevelan_database1', 'clevelan_database2');
// Start Session
session_start();
// Connect to Databases
connectdb($dbserver, $dbuser[0], $dbpass[0], $dbname[0]);
connectdb2($dbserver, $dbuser[1], $dbpass[1], $dbname[1]);
// Database 1 Connection
function connectdb($dbserver, $dbuser, $dbpass, $dbname) {
// connects to db
global $connection;
$connection = @mysql_connect($dbserver, $dbuser, $dbpass) or die ("could not connect to server");
$db = @mysql_select_db($dbname, $connection) or die ("could not select databsase");
return $connection;
// Database 2 Connection
function connectdb2($dbserver, $dbuser, $dbpass, $dbname) {
// connects to db
global $connection2;
$connection2 = @mysql_connect($dbserver, $dbuser, $dbpass) or die ("could not connect to server");
$db2 = @mysql_select_db($dbname, $connection2) or die ("could not select databsase");
return $connection2;
//End of Code Within the "common.php"
From within any page of the website, I want to access both connections by placing an include at the top of each page:
include_once("lib/common.php");
Currently, when I run the code above, any page within the website (the home page) provides error messages with regards to database connectivity (the pages are looking for there content from within the second database. It's as if the second database is the only database seen by the website.
I need help figuring out how I can have two MySQL databases open at the same time (the second database will only be open for short periods of time and then closed). But the main database is always open.Create one project using one copy of the exact tables.
create 2 different sessions.xml files each pointing to the same project. Set the login information in the sessions.xml files.
That should work fine.
Peter -
Trying to Install RMS application 13.2.2 and I get past the pre-installation checks and when I get to the Data Source details and enter the data source details with the check box checked to validate the schema/Test Data Source I get the following error:
Error Connecting to database URL jdbc:oracle:oci:@rmsdbtst as user rms13 java.lang.Exception:UnsatisfiedLinkError encountered when using the Oracle driver. Please check that the library path is set up properly or switch to the JDBC thin client oracle/jdbc/driver/T2CConnection.getLibraryVersioNumber()
Checks performed:
RMS Application code location and directory contents:
[oracle@test-rms-app application]$ pwd
/binary_files/STAGING_DIR/rms/application
[oracle@test-rms-app application]$ ls -ltr
total 144
-rw-r--r-- 1 oracle oinstall 272 Dec 7 2010 version.properties
-rw-r--r-- 1 oracle oinstall 405 Jan 16 2011 expected-object-counts.properties
-rw-r--r-- 1 oracle oinstall 892 May 13 2011 ant.install.properties.sample
-rw-r--r-- 1 oracle oinstall 64004 Jun 6 2011 build.xml
drwxr-xr-x 9 oracle oinstall 4096 Jun 16 2011 rms13
drwxr-xr-x 3 oracle oinstall 4096 Jun 16 2011 installer-resources
drwxr-xr-x 3 oracle oinstall 4096 Jun 16 2011 antinstall
drwxr-xr-x 2 oracle oinstall 4096 Jun 16 2011 ant-ext
drwxr-xr-x 5 oracle oinstall 4096 Jun 16 2011 ant
-rw-r--r-- 1 oracle oinstall 11324 Dec 18 09:18 antinstall-config.xml.ORIG
-rwxr-xr-x 1 oracle oinstall 4249 Dec 18 10:01 install.sh
drwxr-xr-x 4 oracle oinstall 4096 Dec 18 10:06 common
-rw-r--r-- 1 oracle oinstall 16244 Dec 19 10:37 antinstall-config.xml
-rw-r--r-- 1 oracle oinstall 689 Dec 19 10:37 ant.install.log
[oracle@test-rms-app application]$
Application installation:
[oracle@test-rms-app application]$ ./install.sh
THIS IS the driver directory
Verified $ORACLE_SID.
Verified SQL*Plus exists.
Verified write permissions.
Verified formsweb.cfg read permissions.
Verified Registry.dat read permissions.
Verified Java version 1.4.2.x or greater. Java version - 1.6.0
Verified Tk2Motif.rgb settings.
Verified frmcmp_batch.sh status.
WARNING: Oracle Enterprise Linux not detected. Some components may not install properly.
Verified $DISPLAY - 172.16.129.82:0.0.
This installer will ask for your "My Oracle Support" credentials.
Preparing installer. This may take a few moments.
Your internet connection type is: NONE
Integrating My Oracle Support into the product installer workflow...
[move] Moving 1 file to /binary_files/STAGING_DIR/rms/application
Installer preparation complete.
MW_HOME=/u01/app/oracle/Middleware/NewMiddleware1034
ORACLE_HOME=/u01/app/oracle/Middleware/NewMiddleware1034/as_1
ORACLE_INSTANCE=/u01/app/oracle/Middleware/NewMiddleware1034/asinst_1
DOMAIN_HOME=/u01/app/oracle/Middleware/NewMiddleware1034/user_projects/domains/rmsClassDomain
WLS_INSTANCE=WLS_FORMS
ORACLE_SID=rmsdbtst
JAVA_HOME=/u01/app/oracle/jrockit-jdk1.6.0_45-R28.2.7-4.1.0
Launching installer...
To make sure I have connectivity from the app server to the database (on a database server) here are the steps followed:
[oracle@test-rms-app application]$ tnsping rmsdbtst
TNS Ping Utility for Linux: Version 11.1.0.7.0 - Production on 19-DEC-2013 10:41:40
Copyright (c) 1997, 2008, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = test-rms-db.vonmaur.vmc)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = rmsdbtst)))
OK (0 msec)
[oracle@test-rms-app application]$
[oracle@test-rms-app application]$ sqlplus rms13@rmsdbtst
SQL*Plus: Release 11.1.0.7.0 - Production on Thu Dec 19 10:46:18 2013
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@test-rms-app application]$
[oracle@test-rms-app application]$ ping test-rms-db
PING test-rms-db.vonmaur.vmc (192.168.1.140) 56(84) bytes of data.
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=1 ttl=64 time=0.599 ms
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=2 ttl=64 time=0.168 ms
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=3 ttl=64 time=0.132 ms
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=4 ttl=64 time=0.158 ms
64 bytes from test-rms-db.vonmaur.vmc (192.168.1.140): icmp_seq=5 ttl=64 time=0.135 ms
--- test-rms-db.vonmaur.vmc ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
rtt min/avg/max/mdev = 0.132/0.238/0.599/0.181 ms
[oracle@test-rms-app application]$
[oracle@test-rms-app application]$ uname -a
Linux test-rms-app.vonmaur.vmc 2.6.18-128.el5 #1 SMP Wed Jan 21 08:45:05 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
[oracle@test-rms-app application]$
[oracle@test-rms-app application]$ cat /etc/*-release
Enterprise Linux Enterprise Linux Server release 5.3 (Carthage)
Red Hat Enterprise Linux Server release 5.3 (Tikanga)
[oracle@test-rms-app application]$
The database is created and all the batch file scripts have been successfully deployed. Now working on the application server. The Weblogic server is installed and 11g forms and reports are installed successfully.
Any help would be helpful.
Thanks,
Ram.Please check MOS Notes:
FAQ: RWMS 13.2 Installation and Configuration (Doc ID 1307639.1) -
Problem: Failed to open the connection. Error Code 0x800002F4 (-2147482892)
Problem: Failed to open the connection. Error Code 0x800002F4 (-2147482892)
This is on two (2) separate machines. These are NEW INSTALLATION development work stations (laptops). One is Vista (Visual Studio 2008 / Crystal Reports 2008), and the other is Windows XP Pro (Visual Studio 2003 / Crystal Reports XI R1).
I am using EXISTING CODE (established over several years), and EXISTING REPORTS (established over several years). Old development station was XP Pro, as above, and still exists, and still works fine.
I can open the report in Crystal, and see the results just fine. Data for the report is obtained via ODBC.
Can someone identity the actual error by the Error Code above, and advise. Thanks You in Advance.Ok, so let's start at step 1:
SP 1 just released and I'd recommend applying that. The SO is available from here:
https://smpdl.sap-ag.de/~sapidp/012002523100010503722008E/cr2008_sp1.exe
For future reference, msm matching the above SP is here:
https://smpdl.sap-ag.de/~sapidp/012002523100011715292008E/cr121_mm.zip
and msi is here:
https://smpdl.sap-ag.de/~sapidp/012002523100011722132008E/cr121_redist_install.zip
Step 2: a few questions:
a) I am not sure what CR SDK you are using; RDC, .NET? I suspect that you are using the CR assemblies for .NET, but do confirm.
b) what is the database you are connecting to?
c) is this a web or a win app?
Step 3: As the error can mean any number of things (to me it's just means something went wrong during the attempt to connect to the database...), the solution may vary, however the troubleshooting steps remain quite consistent:
1) Do make sure the report is indeed working in the CR 2008 designer (e.g.; make sure "saved data" is not enabled.
2) Try a simple new windows app with one of your reports. See if you have a report with no subreports and use it
3) If that works, use a report with subreports
4) If the above does not work in (1) above, create a new report to the same ODBC connection, do not code any database connection - let the report prompt for the logon parameter (PWD)
5) Run the new report in your new app, enter the PWD when prompted
6) If this works, add your database logon code
7) If that works, add your original report (again, preferably with no subreports)
8) If that fails, ensure that the subreport and main report use the same database connection type (ODBC)
9) If it works, see if you can determine the difference between your old app and the new app.
Ludek -
Hi,
My team and I are trying to resolve this issue. some of our users are having trouble uploading data into the database. this is the error that they are getting.
I would really appreciate it if you could help me get ridd fo this issue.
Server Error in '/' Application.
Unable to connect to database. Check database connection information and make sure the database server is running.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:
System.Runtime.InteropServices.COMException: Unable to connect to database. Check database connection information and make sure the database server is running.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace
below.
Stack Trace:
[COMException (0x81020024): Unable to connect to database. Check database connection information and make sure the database server is running.]
Microsoft.SharePoint.Library.SPRequestInternalClass.PreInitServer(String bstrAbsoluteRequestUrl, String bstrServerRelativeUrl, Int32 lZone, Guid gApplicationId, Guid gSiteId, Guid gDatabaseId,
String bstrDatabaseServer, String bstrDatabaseName, String bstrDatabaseUsername, String bstrDatabasePassword, Boolean fHostHeaderIsSiteName) +0
Microsoft.SharePoint.Library.SPRequest.PreInitServer(String bstrAbsoluteRequestUrl, String bstrServerRelativeUrl, Int32 lZone, Guid gApplicationId, Guid gSiteId, Guid gDatabaseId, String
bstrDatabaseServer, String bstrDatabaseName, String bstrDatabaseUsername, String bstrDatabasePassword, Boolean fHostHeaderIsSiteName) +359
[SPException: Unable to connect to database. Check database connection information and make sure the database server is running.]
Microsoft.SharePoint.Library.SPRequest.PreInitServer(String bstrAbsoluteRequestUrl, String bstrServerRelativeUrl, Int32 lZone, Guid gApplicationId, Guid gSiteId, Guid gDatabaseId, String
bstrDatabaseServer, String bstrDatabaseName, String bstrDatabaseUsername, String bstrDatabasePassword, Boolean fHostHeaderIsSiteName) +479
Microsoft.SharePoint.SPSite.PreinitializeServer(SPRequest request) +666
Microsoft.SharePoint.SPWeb.InitializeSPRequest() +548
Microsoft.SharePoint.SPWeb.EnsureSPRequest() +75
Microsoft.SharePoint.SPWeb.get_Request() +74
Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context) +613
Microsoft.SharePoint.WebControls.SPControl.GetContextWeb(HttpContext context) +41
Microsoft.SharePoint.SPContext.get_Current() +123
CKS.EBE.BlogContext.get_BlogEnabledSite() +37
CKS.EBE.BlogHttpModule._app_PostAuthorizeRequest(Object sender, EventArgs e) +113
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
the description of the error on the server is as follows:
The description for Event ID ( 27745 ) in Source ( Windows SharePoint Services 3 ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use
the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: #50071: Unable to connect to the database MOSS_Content_RBI on BartDB\Bart. Check the database connection information
and make sure that the database server is running..are you using the Aliases for the SQL Server, make sure your account having the correct permission.
If it is your QA farm, you can run the config wizard to fix his problem...
check this post having the similar issue.
http://social.technet.microsoft.com/Forums/sharepoint/en-US/478d6b3a-a51e-48c5-832b-5afb51c69734/unable-to-connect-to-the-sql-content-database-from-sharepoint-web-front-server?forum=sharepointadminlegacy
http://hammad1.wordpress.com/2008/06/04/unable-to-connect-to-database-in-event-logs/
Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog -
Datareader is not able to connect with database-Urgent
Hi All,
All of a sudden the Datareader component in my ML experiment is not able to connect with database with the following error:
[ModuleOutput] DllModuleHost Error: 1 : Program::Main encountered fatal exception: Microsoft.Analytics.Exceptions.ErrorMapping+ModuleException: Error 0000: Internal error ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The value's length for key 'password' exceeds it's limit of '128'.
Module finished after a runtime of 00:00:00.2031339 with exit code -2
Module failed due to negative exit code of -2
It complains about the password being long-but the same credentials I have been using for the last 2 months and still able to use it to run sql queries on that same database using the management portal.
It appears that Azure encrypts the password and that encrypted password is too long...just my guess after looking that the output.Inside Ml it just says as internal error
Would appreciate if someone can point to the issue at the earliest...(There is a demo early next week)
Subscription:Enterprise,
LOCATION: East Asia
Regards,
BiswajitHi,
Please check this url:
https://studio.azureml.net/Home/ViewWorkspace/bc85d4f81d2246c4b1430eb395229a3a?&hashSeg=#Workspaces/Experiments/Experiment/bc85d4f81d2246c4b1430eb395229a3a.f-id.11776ae4400f4c1aa9f58308c30810fa/ViewExperiment
which is an experiment which I created doing save as of the experiment in which the data reader works.
I stripped everything except the data reader and setup the rest of the components...I finally have to write the results back ,so also pulled a Writer component.
Now,the data reader works fine..but the Writer fails:
Error 0071: Incorrect username "acnadmin" or password is passed
Strangely,its the same credentials set in the DataReader.
Looks like all the DataInput/Output components created recently only have the problem.
Once again,while the datareader in this case passes the password in plain text,the writer encrypts,hence fails. -
How to connect one database in two threads?
Dear All,
If anyone can tell me how to connect one database concurrently?
I tried the following idea:
1.create a Hashtable to keep database objects(those databases have been opened)
2.Before openning(connecting) a database:first step is to check the hashtable.
If the the database object is in the hashtable, this object will be returned.
If the datatbase object is not in the hastable, open the database and store this opened database object into the hashtable.
I failed the test of this implementation. My test is:Create two threads (extend java Thread class).In each of these two threads, try to open the same database.Just like the following:
MyThread thread1 = new MyThread();
MyThread thread2 = new MyThread();
thread1.start();
thread2.start();
I guessed the database object in the hashtable would be returned in the second thread.Unfortunatly, I only got an exception which meant the database couldn't be opened twice.It looks like the second thread happened before the opened database object stored into the hashtable.
I cannot figure out if my design is wrong or my test application is wrong.
I really appriatiate your attentions!!!
Luum not sure i follow exactly but in your code add the word synchronise to it and this means only 1 tread can access it at any 1 time.
So your could have a class which is a singleton so it only opens the dbase once and then all other access share your connection.
so
public class foo{
foo INSTANCE = new foo();
private foo(){} //private constructor
then all your methods use foo's internal dbase connection. Am i making sense -
How to connect Oracle database in VC++.06
How to connect Oracle database in VC++.06 please give me details
on the Insert command button and add the following code to the button click event:
try
string results = "";
OracleConnection con = new OracleConnection("DSN=Employee;uid=system;pwd=test");
con.Open();
..................................................................... -
Unable to Connect to database server
Hi All,
I have installed Oracle 11g R2 database, I used it for almost a month now and then today when I tried to log in into it I am getting this error.
An error was encountered performing the requested operation:
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
Vendor code 12505)
I opened the enterprise manager and found that the database instance & Agent Connection Instance was down, when I tried to start that I got this error,
" SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 22 15:48:40 2013 Copyright (c) 1982, 2010, Oracle. All rights reserved. SQL> SQL> ERROR: ORA-12640: Authentication adapter initialization failed "
lsnrctl status output:
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
Start Date 22-AUG-2013 15:38:25
Uptime 0 days 0 hr. 53 min. 40 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File C:\app\psabneka\product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File c:\app\psabneka\diag\tnslsnr\psabneka-lap\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>
Please suggest some workaround.
-PrashantPlease, post:
type C:\app\psabneka\product\11.2.0\dbhome_1\network\admin\listener.ora
hope this helps -
Connecting to database in a thread class
HI,
I am have a problem when trying to get a conneciton to a database. I am trying to create the connection in a class that extends Thread.
Everythign else is set up correctly, i have ran the same code from the main class of my project and it works fine, the problem occurs when I try to get the connection from the class spawned by the main class.
The exception thrown is an SQL exception: No suitable driver found, however the driver was loaded previously (no class not found exception was thrown when loading).
The only reason I can think of that coudl be causing a problem is the fact the class creating the connection extends thread and runs in the run method i.e. a different thread.
Does anybody know of any issues regarding threads and JDBC?
NOTE: I and using the COM.ibm.db2.jdbc.net.DB2Driver for connecting to DB2.
Cheers :)Here is the output
Driver loaded
Authorising for: test - testpass
Protocol connecting to database
Exception in Protocol: java.sql.SQLException: No suitable driver
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:532)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at baeauthserver.AuthProtocol.getPMConnection(AuthProtocol.java:66)
at baeauthserver.AuthServerThread.run(AuthServerThread.java:38)The program is a server daemon or service that listens for connections from a client. On connection the server spawns a "work" thread to deal with authorising the user and creating a database connection. I can make a connection in the main server class (i.e. the main thread) but as soon as I move this to the "work" class it seems to lose the driver.
I've just done some more tests and I can't even grab the driver as a driver object on the work thread so it's not just the getConnection method.
I'm initialising the driver in a static block in the main server program. I've moved it around to various constructors on both the main class and the work class to no avail.
It has me stumped so far :p
Thanks for the input though :) -
RFC system error in system/destination 00024No connect to database, sessio
Hi Experts,
I am getting the below mentioned error while transporting the TO.Although the transport was successful, Please let me know how to solve the probblem.
RFC system error in system/destination Message no.XT107
Diagnosis:
an error occured during RFC communications.
Function:TMS_TP_SHOW_BUFFER
RFC message :00024N0 connect to database, session terminated
System responce:
The function terminates.
Procedure: correct the error on the whole system and execute the command again.
Many thanks in advance.
Regards,
SuneelHi ,
sm59- find - TMSADM*- got following --
TMSADMDV2.DOMAIN_DV2 3
TMSADMPRD.DOMAIN_DV2 3
TMSADMQA2.DOMAIN_DV2 3
when i was checked(test - authorazation) for DV2 and QA2 it shows following error
Connection test TMSADMDV2.DOMAIN_DV2
Connection type: R/3 connection
Cancel User TMSADM has no RFC authorization for function group SYST .
Connection test TMSADMDV2.DOMAIN_DV2
Connection type: R/3 connection
Cancel User TMSADM has no RFC authorization for function group SYST .
But FOR PRD IT SHOWS
Connection test TMSADMPRD.DOMAIN_DV2
Connection type: R/3 connection
Cancel At least three characters must be different in old/new code
pLEASE HELP ME TO RESOLVE THE ISSUE
rEGARDS
mohsin
+91-9867577675 -
Problem in connecting to database from webdynpro for java
Hi
I have a problem in connecting to database from webdynpro application
I am using oracle 10 express edition as database and was able to connect to database from a java application.But was unable to connect from a webdynpro for java.
<b>I guess webdynpro for java uses open sql instead of vendor sql(I looked in the visual admin ,DB is using open sql) so unable to connect to database.Am i right.?</b>
Do i need to make any settings in the visual admin to make it work?
How to solve this problem.Please give me pointers
Thanks
BalaHi,
For connecting to Oracle, either you can use the normal JDBC connectivty code directly which is given below :
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@Oracle_server_ip:Oracle port:SID of the Database","user_name","password");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("your query");
In case you want to fetch data through ejbs, these are the steps to be followed :
1) Open the J2EE perspective
2) Create an EJB Module project
3) Right click on ejbModule, create a new EJB (select your EJB type)
4) While creating the ejb itself, you can add business methods by clicking Next in the UI. Another option is after creating the ejb, write the method in the bean, then select the method from ejb-jar.xml -> <bean name> ->method. Right click and select propogate to local & remote.
5) Double click on ejb-j2ee-engine.xml. select your bean and specify a Jndi name for eg: MyJndi.
6) Right click on the EJB project and add classes12.zip file (provided by Oracle) to its build path. (under libraries tab). Also check the same file under Order & Export.
7) Create an Enterprise Application project.
8) Right click on the EJB module project and select add to EAR project, then select the created EAR project.
9) Right click on the EJB project, select Build EJB Archive
10) Right click on the EAR project, select Build Application Archive
11) Open the WebDynpro perspective, open a new project, right click on the project ->properties. Do the following configurations :-
Java Build path - select the EJB project from projects , check the selected project under Order & Export
Project references select the EAR project
WebDynpro references select sharing references tab, click add & make an entry as : <vendor>/<EAR project name without .ear extension>
You can find the vendor name under application-j2ee-engine.xml file of the EAR project. By default it is sap.com. So if my EAR projects name is ABC, my entry would look like sap.com/ABC
12) Now the configurations are over and the EJB can be invoked by writing the client code inside the webdynpro component. Like:
InitialContext context = new InitialContext();
Object obj = context.lookup("MyJndi");
MyEJBHome home = MyEJBHome)PortableRemoteObject.narrow(obj,MyEJBHome.class);
MyEJB mybean = home.create();
int a = 0;
a= mybean.add(10,15);
wdContext.currentContextElement().setSum(a);
where MyEJB is my EJB name and MyJndi is my JNDI name
To connect to Oracle , you can write the usual Java code (given below) as a business methos of the ejb (similar to add() method in the example). And access it like mybean.<businessMethodName>().
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@Oracle_server_ip:Oracle port:SID of the Database","user_name","password");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("your query");
Extracted from Re: Webdynpro and Oracle
http://help.sap.com/saphelp_webas630/helpdata/en/b0/6e62f30cbe9e44977c78dbdc7a6b27/frameset.htm
May be of use to understand the VA Conf /people/varadharajan.krishnasamy/blog/2007/02/27/configuring-jdbc-connector-service-to-perform-database-lookups
Regards
Ayyapparaj -
How to capture the exact SQL exception for failure to connect to database
Hi, i would like to capture the exact exception for failure to connect to a Oracle 9i database (via JDBC). I learnt that there is specific code or exception that can be captured, so that a more proper error message can be thrown out like "Failure to connect to database" can be displayed. Anyone know how to go about doing it? thanks
That depends on your database vendor, I believe. (Unless there's a SQL standard for states and codes that I'm unaware of.)
Personally, I wouldn't worry about "catching" a particular code. (You've already caught the exception - that's the best you can do.) I'd report the error code and state and just look up what it means when I got one.
Hopefully you won't be catching exceptions. They're supposed to be rare. - MOD
Maybe you are looking for
-
How do I keep my emails in Apple mail after they have been downloaded from exchange server
Hi I have an urgent issue with my work email. I have used Apple Mail to read and store my work email right off my work Exchange server - without any problem. All was fine, and for what seems a very long time, I happily used both my win 7 laptop at wo
-
Error while loading data from DS into cube
Hello All I am getting the below error while loading data from Data source to the cube. Record 1 :Time conversion from 0CALDAY to 0FISCPER (fiscal year ) failed with value 20070331 Wht am i suppose to do? Need ur input in this regard. Regards Rohit
-
Need new computer for high graphic gaming without breaking the bank, any suggestions?
Hi I've asked before about upgrading my current laptop, which the only bad thing about is the graphics card. Now I have given up on that (unless you do know a way) and am searching for a new computer, laptop or desktop, it doesn't matter to me. But
-
Sending email with Entourage worked, but Apple Mail fails
I want to migrate from Entourage to Apple Mail. However sending emails using the smtp of my hosted website, fails every time. I use the same SMTP settings as configured in Entourage, but the connection manager cannot connect to these smtp servers. Wh
-
Support for Panasonic LX3 RAW files in Lightroom (Windows Vista)
I have just bought a Panasonic DMC LX3 and have upgraded to CS4 on my desktop machine and downloaded ACR 5.2 to support the Panasonic RAW files. I run Lightroom 2.1 on my laptop and Lightroom is unable to support these RAW files as yet. Will Lightroo