• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception occuring while using jdbc type1 driver

 
shwetanksk sharma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my program
here dsn1 is the name of DSN created by me for oracle 10g



and following is the output --->
driver loaded
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.lara.A.main(A.java:07)

Please kindly someone provide me the solution for this exception
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch. What kind of DB are you trying to access? Does that SQL statement run fine if you connect directly to the DB (using whatever tools the DB provides)?
 
shwetanksk sharma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Welcome to JavaRanch. What kind of DB are you trying to access? Does that SQL statement run fine if you connect directly to the DB (using whatever tools the DB provides)?


Here are the details of my Database that i am using
Version
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Beta
PL/SQL Release 10.2.0.1.0 - Beta
CORE 10.2.0.1.0 Beta
TNS for 32-bit Windows: Version 10.2.0.1.0 - Beta
NLSRTL Version 10.2.0.1.0 - Beta

Database
NAME XE
CREATED 08/27/2013 11:07:54 PM
RESETLOGS_TIME 08/27/2013 11:07:56 PM
PRIOR_RESETLOGS_CHANGE# 1
PRIOR_RESETLOGS_TIME 10-OCT-05
LOG_MODE NOARCHIVELOG
CHECKPOINT_CHANGE# 5928553
ARCHIVE_CHANGE# 5873855
OPEN_RESETLOGS NOT ALLOWED
VERSION_TIME 08/27/2013 11:07:54 PM
OPEN_MODE READ WRITE
PROTECTION_MODE MAXIMUM PERFORMANCE
PROTECTION_LEVEL UNPROTECTED
REMOTE_ARCHIVE ENABLED
DATABASE_ROLE PRIMARY
ARCHIVELOG_CHANGE# 187859
SWITCHOVER_STATUS SESSIONS ACTIVE
DATAGUARD_BROKER DISABLED
GUARD_STATUS NONE
FORCE_LOGGING NO

and the SQL statement run fine when i connect directly to the DataBase
 
shwetanksk sharma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Exception is arising due to this statement that is
Connection con = DriverManager.getConnection("jdbcdbc:dsn1","system","lara");
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using the JDBC/ODBC bridge with an Oracle DB? Oracle DBs come with their own JDBC drivers - that's what you should use.
 
shwetanksk sharma
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Why are you using the JDBC/ODBC bridge with an Oracle DB? Oracle DBs come with their own JDBC drivers - that's what you should use.


I am using this as i want to learn type 1 driver
what is the cause of the following exception please provide some solution
Exception in thread "main" java.sql.SQLException: [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle on SQL_HANDLE_ENV failed
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using this as i want to learn type 1 driver

In theory that is a commendable attitude, but in this case it has so many drawbacks as to make it a bad choice of subject to learn. Don't ever use the JDBC/OBDC bridge unless you absolutely, positively have to - and that is never the case for any of the serious DBs like Oracle.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moreover, the ODBC bridge is going to be removed in Java 8. It's not a technology worth learning really.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic