Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2010
    Location
    Jamshoro, Satabo Khairpur Mirs
    Posts
    21
    Rep Power
    0

    Default JDBC Problem On linux

    Hi dear pros Im using LinuxMint 10 now a days Im trying jdbc programming on this OS. so wrote my program like we do on windows following is the code:

    Java Code:
    package som.java.dev.arshay.db;
    
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    
    public class DBTest {
    	
    	public DBTest(){
    		try{
    			Class.forName("sun.jdbc.odbc.JdbcOdbc");			
    			String url="jdbc:odbc:mydatabase";
    			Connection con=DriverManager.getConnection(url);
    			Statement st=con.createStatement();
    			String sql="select FirstName from Employees where City='satabo' ";
    			ResultSet rs=st.executeQuery(sql);
    			while(rs.next()){
    				String fName=rs.getString("FirstName");				
    			}
    		}catch(Exception e){e.printStackTrace();}		
    	}
    	
    	public static void main(String[] args) {
    
           DBTest object = new DBTest();
           
    	}
    
    }
    but it throws an exception:
    java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbc

    please! suggest me a solution
    Thanks

  2. #2
    Join Date
    Jul 2010
    Location
    Jamshoro, Satabo Khairpur Mirs
    Posts
    21
    Rep Power
    0

    Default

    If I write Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); instead of
    Class.forName("sun.jdbc.odbc.JdbcOdbc"); same problem occurs

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,792
    Rep Power
    19

    Default

    What database are you trying to connect to?
    I'd get the proper driver jar file for that database rather than use the JDBC-ODBC bridge.

    As for why it's not working, are you using a Sun (or Oracle) JDK?

Similar Threads

  1. Problem with FreeRapid in Linux
    By jacatone in forum Java Applets
    Replies: 5
    Last Post: 06-13-2010, 05:03 AM
  2. problem in executing linux command
    By Basit56 in forum New To Java
    Replies: 1
    Last Post: 02-08-2010, 03:53 PM
  3. Replies: 6
    Last Post: 04-08-2009, 04:05 AM
  4. problem in installing app on Tomcat 6 at linux
    By sspbond007 in forum Advanced Java
    Replies: 2
    Last Post: 01-03-2009, 06:36 PM
  5. problem with ServerSocket on Linux
    By gabriel in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 04:46 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •