Delete comment from: Javarevisited

Er. Abhay Mishra said...

import java.lang.Exception;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
public class java
{
static String url ="jdbc:odbc:vinn";
static Connection con =null;
public static void main(String[] args) throws SQLException {
Connection con =getOracleJDBCConnection();
if(con!=null)
{
System.out.println("got connection");
DatabaseMetaData meta=con.getMetaData();
System.out.println("Driver Name:"+meta.getDriverName());
System.out.println("Driver Version:"+meta.getDriverVersion());
}
else{
System.out.println("could not find connection");
}
}
public static Connection getOracleJDBCConnection()
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println("ClassNotFoundException:");
System.err.println(e.getMessage());
}
try{
con=DriverManager.getConnection(url);
}
catch(SQLException ex)
{
System.err.println("SQLException:" + ex.getMessage());
}
return con;
}}

when i compile this program an error is occured i.e. cannot find sysmbol java.lang in the 29th line ....it's a program for testing jdbc connection driver name and its version...


how to resolve this issue....
i m compiling this program in the cmd

Jun 29, 2014, 10:32:58 AM


Posted to Java Program to connect Oracle Database with Example - JDBC Tutorial Sample Code

Google apps
Main menu