ODBC connectivity for ORACLE RDB
Hi,
I am trying to configure ODBC Agent with oracle to access ORACLE RDB.
I have installed ORACLE RDB ODBC driver and created SYSTEM DSN named
"dcprdb".
My configuration files are as follows
inithsodbc.ora (at E:\oracle\ora81\hs\admin)
HS_FDS_CONNECT_INFO = dcprdb
HS_FDS_TRACE_LEVEL = 0
HS_FDS_TRACE_FILE_NAME = hsodbc.trc
tnsnames.ora (at E:\oracle\ora81\network\ADMIN)
hsodbc =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ip_address)(PORT = 1527))
(CONNECT_DATA =
(SID = hsodbc)
(HS=)
listener.ora (at E:\oracle\ora81\network\ADMIN)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = hsodbc)
(ORACLE_HOME = E:\oracle\ora81)
(PROGRAM = hsodbc)
CONNECT_TIMEOUT_LISTENER = 0
I restarted the TNS Listener service. Then, I have created DB link using the following command:
CREATE DATABASE LINK hsodbc
CONNECT TO <user_name> IDENTIFIED BY <password>
USING 'hsodbc';
When I executed the following query, I am getting the following error message:
select * from model@hsodbc;
Error Message:
select * from modl@hsodbc
ERROR at line 1:
ORA-02068: following severe error from HSODBC
ORA-28511: lost RPC connection to heterogeneous remote agent using
SID=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=207.53.38.129)(PORT=
1527)))(CONNECT_DATA=(SID=hsodbc)))
I am using Windows 2000 OS and Oracle8i Enterprise Edition Release 8.1.7.0.0
When I executed "tnsping dcprdb" at E:\oracle\ora81\bin, it works well. (see, below)
E:\oracle\ora81\bin>tnsping dcprdb
TNS Ping Utility for 32-bit Windows: Version 8.1.7.0.0 - Production on 20-JAN-20
04 19:41:06
(c) Copyright 1997 Oracle Corporation. All rights reserved.
Attempting to contact (ADDRESS=(PROTOCOL=TCP)(HOST=ip_address)(PORT=1527))
OK (810 msec)
E:\oracle\ora81\bin>
Thanks in Advance
Thiru
try to write into file
tnsnames.ora (at E:\oracle\ora81\network\ADMIN)
hsodbc =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ip_address)(PORT = 1527))
(CONNECT_DATA =
(SID = hsodbc)
(HS=OK) --this is important
Similar Messages
-
Can't Create the ODBC connection for Oracle 10g
Hi,
I am working with Oracle 10g Database Release 2 in windows XP professional. I am trying to create an ODBC connection for oracle but become failure because its generating the following errors:
system error code 998
could not locate the setup or translator library
Please help me how can I solve this problem and create the ODBC connection for oracle 10g database.
Best Regards,mwz wrote:
I am trying to create an ODBC connection for oracle but become failure because its generating the following errors:
system error code 998
could not locate the setup or translator libraryThe symptom described is typical of an incorrect system env PATH setting (used by the data source admin tool), compared to that of the Oracle Home (specifically, path $OH/bin). The odbc driver config routine will search directories listed in PATH variable for necessary libraries (Client dll's). If some library fails to load (from e.g. oraoci*.dll or oraclient10.dll) it will probably error out, as in your case.
Are you creating the odbc dsn on the databse server host or on some other machine? I.e. are you using the db host as a client or not? -
Odbc connectivity for oracle lite
Can Oracle lite be connected through ODBC for a windows front end application developed (other than developer 2000)
Hi
Can anyone please give the connect string to connect to Oracle Lite through ODBC driver from a VB.NET windows front end application?
Regards
Sangeetha -
ODBC Connectivity for Oracle 8.1.6
Hi, I am trying to find odbc.ini file so as to connect using ODBC, but am not being successful. Can anybody help?
Are you trying to connect to a Linux database from a Windows client, or are you trying to connect from a Linux client? Which ODBC driver are you using?
Justin Cave -
Hi,
This is Sathish, I am trying to create a report and retrieve data through stored procedure using ODBC Connection. When connecting to the Stored Procedure it is showing Database Connection Error 42000:[Microsoft][ODBC driver for oracle] Syntax error or access violation' Error.
CRXI R2, Oracle 9i.
What do i do to solve this issue.
Regards,
SathishHi Satish
It could be an issue with the driver.
You can try with the OLEDB n Oracle native connection to test if the issue persists.
Also you can refer to the [Troubleshooting Database Connectivity for Crystal Reports|http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/d05b3bb7-0f28-2c10-4ea3-84dbdc4e414e&overridelayout=true]
Hope this helps!!
Regards
Sourashree -
Re: 32 Bit ODBC Driver for Oracle 11g 11.2.0.1.0
Hi,
Were you able to resolve the problem with these troubleshooting measures ?
Please let me know since i am facing similar issues like yours.
I am using a Windows 7 64 bit and from QTP installed on this machine , i am trying to connect to Oracle database.
Now initially i installed a 64 bit ODBC for Oracle . But when i did that and ran the Script below :
Set objDatabase = CreateObject("ADODB.Connection")
Set rs=createobject("adodb.recordset")
objDatabase.open "DRIVER={Oracle in OraClient11g_home1} ; DATA SOURCE=Oracle; SERVER= xyz ; DATABASE=abc1; UID=abc ; PASSWORD= abc123;"
rs.Open "select * from tablename", objDatabase
'result1 = objDatabase.Execute("select * from tablename")
'msgbox result1
Do while not rs.eof
print rs.fields("columnname")
rs.movenext
Loop
print rs.fields("columnname")
it gives me an error
“[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application”
So i am assuming that i need to install the 32 bit ODBC drivers for Oracle as well in addition to the already installed 64 bit drivers ..
Any thoughts on this ?64 bit apps need 64 bit Oracle client software.
32 bit apps need 32 bit Oracle client software.
You should be able to tell the bit-ness of the app by checking the Process tab in task manager to see if it has *32 next to it.
You can install both 32 bit and 64 bit Oracle client software on the same box, but you need to do it into different homes, and different oracle_base should also be used.
There isnt an Oracle client install bundle that installs both, you'll need to do each separately.
Hope it helps,
Greg -
ODBC connectivity between Oracle 11G and MSSQL Server on Solaris 10
When we were running in 10G, I was able to successfully configure hsodbc using unixODBC and freeTDS to allow for an ODBC connection between Oracle and MSSQL Server.
A few weeks ago we upgraded to 11G and I've been struggling to get the connectivity (dg4odbc) working.
In our 10g environment unixODBC and freeTDS were compiled as 32-bit. I have recompiled them as 64-bit and switched over to an 11G listener and I am getting the following error:
ERROR at line 1:
ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
here are my configuration files:
/usr/local/unixODBC/etc[PPRD]> more odbc.ini
[ODBC Data Sources]
identipass = MS SQL Server
[identipass]
Driver = /usr/local/freetds/lib/libtdsodbc.so
Setup = /usr/local/freetds/lib/libtdsodbc.so
Description = MS SQL Server
Trace = 1
TraceFile = /export/home/oracle/ODBC/odbc.trace
Server = stormwind
QuoteID = Yes
AnsiNPW = No
Database = identipass
Port = 1433
TDS_Version = 8.0
[Default]
Driver = /usr/local/freetds/lib/libtdsodbc.so
/usr/local/unixODBC/etc[PPRD]> more odbcinst.ini
[TDS]
Description=FreeTDS driver
Driver=/usr/local/freetds/lib/libtdsodbc.so
Setup=/usr/local/freetds/lib/libtdsodbc.so
Trace=Yes
TraceFile=/tmp/freetds.log
FileUsage=1
UsageCount=2
tnsnames.ora
identipass =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = localhost)(PORT = 1522))
(CONNECT_DATA =
(SID = identipass)
(HS = OK)
listener.ora
LISTENERODBC =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522))
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
SID_LIST_LISTENERODBC=
(SID_LIST=
(SID_DESC=
(SID_NAME=identipass)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1)
(ENV="LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/db_1/lib:/u01/app/oracle/product/11.2.0/db_1/hs/lib")
(PROGRAM=dg4odbc)
And finally, output from the trace file:
/u01/app/oracle/product/11.2.0/db_1/hs/log[PPRD]> more identipass_agt_1381.trc
Oracle Corporation --- THURSDAY NOV 18 2010 16:00:16.010
Heterogeneous Agent Release
11.2.0.1.0
Oracle Corporation --- THURSDAY NOV 18 2010 16:00:16.008
Version 11.2.0.1.0
Entered hgogprd
HOSGIP for "HS_FDS_TRACE_LEVEL" returned "Debug"
Entered hgosdip
setting HS_OPEN_CURSORS to default of 50
setting HS_FDS_RECOVERY_ACCOUNT to default of "RECOVER"
setting HS_FDS_RECOVERY_PWD to default value
setting HS_FDS_TRANSACTION_LOG to default of HS_TRANSACTION_LOG
setting HS_IDLE_TIMEOUT to default of 0
setting HS_FDS_TRANSACTION_ISOLATION to default of "READ_COMMITTED"
setting HS_NLS_NCHAR to default of "AL32UTF8"
setting HS_FDS_TIMESTAMP_MAPPING to default of "DATE"
setting HS_FDS_DATE_MAPPING to default of "DATE"
setting HS_RPC_FETCH_REBLOCKING to default of "ON"
setting HS_FDS_FETCH_ROWS to default of "100"
setting HS_FDS_RESULTSET_SUPPORT to default of "FALSE"
setting HS_FDS_RSET_RETURN_ROWCOUNT to default of "FALSE"
setting HS_FDS_PROC_IS_FUNC to default of "FALSE"
setting HS_FDS_CHARACTER_SEMANTICS to default of "FALSE"
setting HS_FDS_MAP_NCHAR to default of "TRUE"
setting HS_NLS_DATE_FORMAT to default of "YYYY-MM-DD HH24:MI:SS"
setting HS_FDS_REPORT_REAL_AS_DOUBLE to default of "FALSE"
setting HS_LONG_PIECE_TRANSFER_SIZE to default of "65536"
setting HS_SQL_HANDLE_STMT_REUSE to default of "FALSE"
setting HS_FDS_QUERY_DRIVER to default of "TRUE"
HOSGIP returned value of "FALSE" for HS_FDS_SUPPORT_STATISTICS
Parameter HS_FDS_QUOTE_IDENTIFIER is not set
setting HS_KEEP_REMOTE_COLUMN_SIZE to default of "OFF"
setting HS_FDS_GRAPHIC_TO_MBCS to default of "FALSE"
setting HS_FDS_MBCS_TO_GRAPHIC to default of "FALSE"
Default value of 64 assumed for HS_FDS_SQLLEN_INTERPRETATION
setting HS_CALL_NAME_ISP to "gtw$:SQLTables;gtw$:SQLColumns;gtw$:SQLPrimaryKeys;gtw$:SQLForeignKeys;gtw$:SQLProcedures;gtw$:SQLSt
atistics;gtw$:SQLGetInfo"
setting HS_FDS_DELAYED_OPEN to default of "TRUE"
setting HS_FDS_WORKAROUNDS to default of "0"
Exiting hgosdip, rc=0
ORACLE_SID is "identipass"
Product-Info:
Port Rls/Upd:1/0 PrdStat:0
Agent:Oracle Database Gateway for ODBC
Facility:hsa
Class:ODBC, ClassVsn:11.2.0.1.0_0008, Instance:identipass
Exiting hgogprd, rc=0
Entered hgoinit
HOCXU_COMP_CSET=1
HOCXU_DRV_CSET=873
HOCXU_DRV_NCHAR=873
HOCXU_DB_CSET=873
HOCXU_SEM_VER=112000
Entered hgolofn at 2010/11/18-16:00:16
HOSGIP for "HS_FDS_SHAREABLE_NAME" returned "/usr/local/unixODBC/lib/libodbc.so"
Entered hgolofns at 2010/11/18-16:00:16
symbol_peflctx=0x7a715450
hoaerr:0
Exiting hgolofns at 2010/11/18-16:00:16
Exiting hgolofn, rc=0 at 2010/11/18-16:00:16
HOSGIP for "HS_OPEN_CURSORS" returned "50"
HOSGIP for "HS_FDS_FETCH_ROWS" returned "100"
HOSGIP for "HS_LONG_PIECE_TRANSFER_SIZE" returned "65536"
HOSGIP for "HS_NLS_NUMERIC_CHARACTER" returned ".,"
HOSGIP for "HS_KEEP_REMOTE_COLUMN_SIZE" returned "OFF"
HOSGIP for "HS_FDS_DELAYED_OPEN" returned "TRUE"
HOSGIP for "HS_FDS_WORKAROUNDS" returned "0"
HOSGIP for "HS_FDS_MBCS_TO_GRAPHIC" returned "FALSE"
HOSGIP for "HS_FDS_GRAPHIC_TO_MBCS" returned "FALSE"
Invalid value of 64 given for HS_FDS_SQLLEN_INTERPRETATION
treat_SQLLEN_as_compiled = 1
Exiting hgoinit, rc=0 at 2010/11/18-16:00:16
Entered hgolgon at 2010/11/18-16:00:16
reco:0, name:identipass, tflag:0
Entered hgosuec at 2010/11/18-16:00:16
Exiting hgosuec, rc=0 at 2010/11/18-16:00:16
HOSGIP for "HS_FDS_RECOVERY_ACCOUNT" returned "RECOVER"
HOSGIP for "HS_FDS_TRANSACTION_LOG" returned "HS_TRANSACTION_LOG"
HOSGIP for "HS_FDS_TIMESTAMP_MAPPING" returned "DATE"
HOSGIP for "HS_FDS_DATE_MAPPING" returned "DATE"
HOSGIP for "HS_FDS_CHARACTER_SEMANTICS" returned "FALSE"
HOSGIP for "HS_FDS_MAP_NCHAR" returned "TRUE"
HOSGIP for "HS_FDS_RESULTSET_SUPPORT" returned "FALSE"
HOSGIP for "HS_FDS_RSET_RETURN_ROWCOUNT" returned "FALSE"
HOSGIP for "HS_FDS_PROC_IS_FUNC" returned "FALSE"
HOSGIP for "HS_FDS_REPORT_REAL_AS_DOUBLE" returned "FALSE"
using identipass as default value for "HS_FDS_DEFAULT_OWNER"
HOSGIP for "HS_SQL_HANDLE_STMT_REUSE" returned "FALSE"
Entered hgocont at 2010/11/18-16:00:16
HS_FDS_CONNECT_INFO = "identipass"
RC=-1 from HOSGIP for "HS_FDS_CONNECT_STRING"
Entered hgogenconstr at 2010/11/18-16:00:16
dsn:identipass, name:identipass
optn:
Entered hgocip at 2010/11/18-16:00:16
dsn:identipass
Exiting hgocip, rc=0 at 2010/11/18-16:00:16
Exiting hgogenconstr, rc=0 at 2010/11/18-16:00:16
Entered hgopoer at 2010/11/18-16:00:16
hgopoer, line 233: got native error 0 and sqlstate ; message follows...
Exiting hgopoer, rc=0 at 2010/11/18-16:00:16
hgocont, line 2753: calling SqlDriverConnect got sqlstate
Exiting hgocont, rc=28500 at 2010/11/18-16:00:16 with error ptr FILE:hgocont.c LINE:2772 ID:Something other than invalid authoriza
tion
Exiting hgolgon, rc=28500 at 2010/11/18-16:00:16 with error ptr FILE:hgolgon.c LINE:781 ID:Calling hgocont
Entered hgoexit at 2010/11/18-16:00:16
Exiting hgoexit, rc=0
Can anyone help me see what I'm missing?Thank you for your response.
I modified the envs LD_LIBRARY_PATH parameter in my SID_LIST_LISTENERODBC to be:
(ENV="LD_LIBRARY_PATH=/usr/local/freetds/lib:/usr/local/unixODBC/lib:/u01/app/oracle/product/11.2.0/db_1/lib:/
u01/app/oracle/product/11.2.0/db_1/hs/lib")
and bounced the listener, but I'm still getting the same error.
I do not have a lib64 directory in my Freetds installation, but all the files in the lib directory are 64-bit.
Here is a listing of my DG4ODBC init file:
/u01/app/oracle/product/11.2.0/db_1/hs/admin[PPRD]> more initidentipass.ora
# This is a sample agent init file that contains the HS parameters that are
# needed for an ODBC Agent.
# HS init parameters
HS_FDS_CONNECT_INFO = identipass
#HS_FDS_TRACE_LEVEL = 0
HS_FDS_TRACE_LEVEL = Debug
HS_FDS_SHAREABLE_NAME = /usr/local/unixODBC/lib/libodbc.so
HS_FDS_SUPPORT_STATISTICS=FALSE
HS_LANGUAGE=AMERICAN.AMERICA.WE8ISO8859P15
# ODBC specific environment variables
set ODBCINI=/usr/local/unixODBC/etc/odbc.ini
# Environment variables required for the non-Oracle system
#set <envvar>=<value>
Thanks for your help with this!
Catina -
Where can I download the ODBC driver for Oracle 10g XE?
where can I download the ODBC driver for Oracle 10g XE?
I need the ODBC drivers for windows 7 x64, I installed Oracle Database 10g Express Edition, the use and connects with RazorSQL well, I just want to make a connection THROUGH ConnectionString language using the ODBC driveralready checked these http://www.connectionstrings.com/oracle, I need Help Please.
-
[Microsoft][ODBC driver for Oracle]Syntax error or access violation
Hi,
When I am trying to connect to Oracle 8.1.6 database using Microsoft ODBC driver for Oracle. The connection is established.
But while creating CallableStatement, I am getting error "[Microsoft][ODBC driver for Oracle]Syntax error or access violation".
What I need to do to resolve this problem.
RajHi Satish
It could be an issue with the driver.
You can try with the OLEDB n Oracle native connection to test if the issue persists.
Also you can refer to the [Troubleshooting Database Connectivity for Crystal Reports|http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/d05b3bb7-0f28-2c10-4ea3-84dbdc4e414e&overridelayout=true]
Hope this helps!!
Regards
Sourashree -
How to create ODBC connection between Oracle 10g and MS SQL Server
Hi,
Can someone help us with the steps to create an ODBC connection between Oracle APPS using Oracle 10g database and MS SQL Server.
Requirement is to extract the transactional data from MS SQL Server on a daily basis and dump it into Oracle tables for an interface to be run. Currently it is being done through Dataloader tool which we feel is causing the data issue with Arabic characters. We want to create the ODBC directly between Oracle and MS SQL Server and check if the data is being pulled correctly.
The data is in sql server 2000 which has data in Arabic_CI_AS character set which is moved to Oracle 10.2.0.3 database with characterset AL32UTF8. The table data is moved to oracle using the dataloader 3.6 standard edition licensed version. We cannot change the character set of Sql Server 2000.
Please help
Thanks
ShanilHi,
If you're trying to PULL data from SQLServer into an Oracle database, you wouldnt use Oracle ODBC driver for that, so you may want to post in the Heterogeneous Services forum instead:
Heterogeneous Connectivity
If you're trying to PUSH data from SQLServer into an Oracle database, you could use ODBC but most folks use OLEDB for that, and the following note on MOS should help:
How to Create a Sql Server Linked Server With The Oracle Provider for OLE DB (Doc ID 191368.1)
As with any NLS related issue, the first thing to do is dump the codepoints of the data in the Oracle database to see if it is stored validly, rather than relying on what the data "looks like" from some tool or other. It's best to check a single row, with only a few characters in it if you can, and you can do that via
SELECT DUMP(<columname>,1016) FROM <tablename> WHERE ...
Hope it helps,
Greg -
ODBC: connect from oracle to filmaker pro 7 to extract data
sorry for the cross post, i posted this in th ODBC forum, but that's in the windows.net subhead, so idunno.
here is is again:
we have a filemaker pro server and some of the data needs to be imported weekly into an oracle database.
my understanding is this can be done and it is roughed out in the "FileMaker 7 ODBC and JDBC Developer's Guide"...available here if anyone is interested:http://filemaker.custhelp.com/cgi-bin/filemaker.cfg/php/enduser/std_adp.php?p_faqid=5337
however, i know nothing about oracle, but i don't need to since there are people on staff to deal with that. i am presenting this connection option as the best way for the oracle guys here to get the data they need. the other option is for them (non-filemaker savvy people) doing exports and importing them into oracle. they don't want to do this because they don't like filemaker. i believe this whole process would be easier if i keep the oracle guys in what they know and love, oracle. once the extract was properly set up it could be done as cron job. all done.
so my question is, how would one accomplish this?
broad strokes that i could give to the oracle people to direct them.
i figure they could build a small custom app to do this, but i have no idea what is involved with that. or, perhaps the oracle application has the ability to run scripts?
any pointers would be helpful.
thanks!You can use Filemaker's built-in ODBC capability to push data from the FMP database into Oracle. Then you as a FMP developer can take responsibility for getting the data into Oracle and the Oracle guys don't have to deal with FMP at all.
You will need an ODBC driver for Oracle, and an ODBC DSN configured for connecting to the Oracle database. Then you will need to write a simple FMP script that traverses the FMP records you want to push and generate a SQL string that you pass to the Execute SQL script step. Here is an example:
Go to Record/Request/Page [First]
Loop
Execute SQL [No dialog; DSN: myDSN;
Calculated SQL Text: "UPDATE products_description
SET products_viewed=" & myFMPDatabase::Products_Viewed
& " WHERE products_id=" & myFMPDatabase::Products_ID]
Go to Record/Request/Page [Next; Exit after last]
End Loop
This assumes that you have an account with write access to the Oracle database, you understands its schema, and have enough knowledge of SQL to write simple INSERT / UPDATE statements.
Jonathan Monroe
Actual Technologies - ODBC for Mac OS X
http://www.actualtechnologies.com
[email protected] -
Result Sets with the Microsoft ODBC Driver for Oracle
Howdy all.
I have an Oracle database that I have migrated from MSSQL2K. My front end is mostly VB, and I have many (hundreds) DLL's that use ADO to access the database and execute stored procedures in the database. I cannot seem to get result sets from the Oracle procedures. I have tried passing a SYS_REFCURSOR as an IN OUT parameter, and I have tried returning a SYS_REFCURSOR in a function. The Microsoft ODBC Driver for Oracle does not seem to handle the ref cursors. If I use the Oracle ODBC driver, then ref cursors are handled sort of magically. Just like the result sets are in MSSQL with the SQL Server ODBC Driver.
The question that I would like to pose to anybody willing to answer is this: Is there any way to use the Microsoft ODBC Driver for Oracle without changing the way I do the database access (using ADO connection/command/recordset objects)? I need the same DLL's to work on top of both MSSQL and Oracle.
I know that what I want to do is possible using the Oracle ODBC driver, but this will take some major changes to some of my DB components. I am trying to stay away from this, but it looks like I am going to have to go that route - that is unless somebody wows me with a good answer to this post.
wallyAs you are using Microsoft driver which works in XP and does not on Win 2003 you should post this on microsoft forum.
-
How we build Java Database Connectivity for Oracle 8i Database
Can any one send me a sample code for Java Database Connectivity for Oracle 8i Database
it will be a grat help
Thanks & Regards
RasikaYou don't need a DSN if you use Oracle's JDBC driver.
You didn't read ANY of the previous replies. What makes you think this one willk help? Or any instruction, for that matter?
Sounds like you just want someone to give it to you. OK, I'll bite, but you have to figure out the rest:
import java.sql.*;
import java.util.*;
* Command line app that allows a user to connect with a database and
* execute any valid SQL against it
public class DataConnection
public static final String DEFAULT_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
public static final String DEFAULT_URL = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\\Edu\\Java\\Forum\\DataConnection.mdb";
public static final String DEFAULT_USERNAME = "admin";
public static final String DEFAULT_PASSWORD = "";
public static final String DEFAULT_DRIVER = "com.mysql.jdbc.Driver";
public static final String DEFAULT_URL = "jdbc:mysql://localhost:3306/hibernate";
public static final String DEFAULT_USERNAME = "admin";
public static final String DEFAULT_PASSWORD = "";
/** Database connection */
private Connection connection;
* Driver for the DataConnection
* @param command line arguments
* <ol start='0'>
* <li>SQL query string</li>
* <li>JDBC driver class</li>
* <li>database URL</li>
* <li>username</li>
* <li>password</li>
* </ol>
public static void main(String [] args)
DataConnection db = null;
try
if (args.length > 0)
String sql = args[0];
String driver = ((args.length > 1) ? args[1] : DEFAULT_DRIVER);
String url = ((args.length > 2) ? args[2] : DEFAULT_URL);
String username = ((args.length > 3) ? args[3] : DEFAULT_USERNAME);
String password = ((args.length > 4) ? args[4] : DEFAULT_PASSWORD);
System.out.println("sql : " + sql);
System.out.println("driver : " + driver);
System.out.println("url : " + url);
System.out.println("username: " + username);
System.out.println("password: " + password);
db = new DataConnection(driver, url, username, password);
System.out.println("Connection established");
Object result = db.executeSQL(sql);
System.out.println(result);
else
System.out.println("Usage: db.DataConnection <sql> <driver> <url> <username> <password>");
catch (SQLException e)
System.err.println("SQL error: " + e.getErrorCode());
System.err.println("SQL state: " + e.getSQLState());
e.printStackTrace(System.err);
catch (Exception e)
e.printStackTrace(System.err);
finally
if (db != null)
db.close();
db = null;
* Create a DataConnection
* @throws SQLException if the database connection fails
* @throws ClassNotFoundException if the driver class can't be loaded
public DataConnection() throws SQLException,ClassNotFoundException
this(DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_USERNAME, DEFAULT_PASSWORD);
* Create a DataConnection
* @throws SQLException if the database connection fails
* @throws ClassNotFoundException if the driver class can't be loaded
public DataConnection(final String driver,
final String url,
final String username,
final String password)
throws SQLException,ClassNotFoundException
Class.forName(driver);
this.connection = DriverManager.getConnection(url, username, password);
* Get Driver properties
* @param database URL
* @return list of driver properties
* @throws SQLException if the query fails
public List getDriverProperties(final String url)
throws SQLException
List driverProperties = new ArrayList();
Driver driver = DriverManager.getDriver(url);
if (driver != null)
DriverPropertyInfo[] info = driver.getPropertyInfo(url, null);
if (info != null)
driverProperties = Arrays.asList(info);
return driverProperties;
* Clean up the connection
public void close()
close(this.connection);
* Execute ANY SQL statement
* @param SQL statement to execute
* @returns list of row values if a ResultSet is returned,
* OR an altered row count object if not
* @throws SQLException if the query fails
public Object executeSQL(final String sql) throws SQLException
Object returnValue;
Statement statement = null;
ResultSet rs = null;
try
statement = this.connection.createStatement();
boolean hasResultSet = statement.execute(sql);
if (hasResultSet)
rs = statement.getResultSet();
ResultSetMetaData meta = rs.getMetaData();
int numColumns = meta.getColumnCount();
List rows = new ArrayList();
while (rs.next())
Map thisRow = new LinkedHashMap();
for (int i = 1; i <= numColumns; ++i)
String columnName = meta.getColumnName(i);
Object value = rs.getObject(columnName);
thisRow.put(columnName, value);
rows.add(thisRow);
returnValue = rows;
else
int updateCount = statement.getUpdateCount();
returnValue = new Integer(updateCount);
finally
close(rs);
close(statement);
return returnValue;
* Close a database connection
* @param connection to close
public static final void close(Connection connection)
try
if (connection != null)
connection.close();
connection = null;
catch (SQLException e)
e.printStackTrace();
* Close a statement
* @param statement to close
public static final void close(Statement statement)
try
if (statement != null)
statement.close();
statement = null;
catch (SQLException e)
e.printStackTrace();
* Close a result set
* @param rs to close
public static final void close(ResultSet rs)
try
if (rs != null)
rs.close();
rs = null;
catch (SQLException e)
e.printStackTrace();
* Close a database connection and statement
* @param connection to close
* @param statement to close
public static final void close(Connection connection, Statement statement)
close(statement);
close(connection);
* Close a database connection, statement, and result set
* @param connection to close
* @param statement to close
* @param rs to close
public static final void close(Connection connection,
Statement statement,
ResultSet rs)
close(rs);
close(statement);
close(connection);
}% -
64 bit Microsoft ODBC Driver for Oracle
Hi,
Does Microsoft provide a 64 bit ODBC Driver for Oracle and where we can get it?GQ wrote:
Hello,
I am trying to create ODBC connection to Oracle 9i Database on remote server. I am using Windows 2008 64-bit but it is not showing Microsoft ODBC Driver for Oracle. Could any one suggest what to do?\\
ThanksInstall the Oracle client and use the Oracle driver. You're going to need it whether you use the MS driver or Oracles. ODBC drivers do not work apart from the client of the underlying database product.
When you do the install, you will need to do a custom install and specifically select for the Windows components. -
How to establish the ODBC connectivity for Hyperion Brio
Hi Every One,
Please some one let me know how to establish the ODBC connectivity for Hyperion Brio/ interactive reporting studio.?
Thanks & Regards,
Rajcheck out the manual
http://download.oracle.com/docs/cd/E10530_01/doc/epm.931/ir_user.pdf
chapter 15
Edited by: [email protected] on Feb 9, 2010 7:00 AM
Maybe you are looking for
-
My Photoshop elements 11 stopped working app store purchase
I purchased photoshop 11 from the app store and it has stopped working. It crashes during load. (See the code below). I have tried uninstalling and reinstaling. And it did not fix the issue. I found a few others having the same problem with app store
-
HT1937 is there a way i can get a copy of a receipt for an ipad purchased online 2 years ago?
is there a way i can get a copy of a receipt for an ipad purchased 2 years ago online?
-
As in R/3 field EKPO-BSTAE is there any similar field in SRM
As in R/3 field BSTAE is there any similar field in SRM
-
Hi This may be one for the gurus, or they're could be a standard way to do it. I'm looking for some help in designing a database. The problem I have is related to data aging on Oracle instances. I can't find any help on it. The problem I have is that
-
Trouble while uploading ibook through itunes producer
hello all while submitting my epub(mine is an epub3) through itunes producer,i found 3 errors. ERROR 1:Apple's web service operation was not successful ERROR 2:Unable to authenticate the package:B_FUEL_FOR_YOUR_LIFE.itmsp ERROR ITMS-5107:"FuelforYour