javed iqbal

Greenhorn
+ Follow
since Dec 30, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by javed iqbal

whenever I m trying to set the connection with my database i get the following error:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Driver's SQLAllocHandle
on SQL_HANDLE_ENV failed

my code is:

import java.sql.*;

public class testconnection
{



public static void main(String ar[])
{
Connection conn;
Statement stmt;
ResultSet rs;

try
{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc dbc:newdsn","scott","tiger");
stmt=conn.createStatement();
rs=stmt.executeQuery("select * from emp");

while(rs.next())
{
System.out.println(" "+rs.getInt(0)+" "+rs.getString(1));
}

conn.close();
}
catch(Exception e)
{
System.out.println(e);
}

}
}


my dsn name is:newdsn.

please help me to get out of this
I have tried to set the connection with my database (oracle) but every time I run the code I get the following error.

Error: package sun.jdbc does not exist

even though I have set the environment variables

the code is :



Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
conn=DriverManager.getConnection("jdbc dbc:newdsn","scott","tiger");

stmt=conn.createStatement();
rs=stmt.executeQuery("select * from emp");




newdsn is my dsn name

please help
16 years ago