Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Exception occuring while using jdbc type1 driver

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Exception is arising due to this statement that is
Connection con = DriverManager.getConnection("jdbc:odbc:dsn1","system","lara");
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43027
76
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
This will take every ounce of my mental strength! All for a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic