Results 1 to 4 of 4

Thread: SQLException being thrown[Resolved]

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Resolved SQLException being thrown[Resolved]

    Im trying to establish my connection, and I'm getting an sql exception..The error message is: sqlException data source name not found and no default driver specified. I got this code straight out of book. The book is based on 1.4, and I have 1.5, so I don't know if that might have something to do with the default driver.

    Code:
    import java.sql.*;
    
    public class JDBCConnection2
    {
    	/** Default Constructor */
    	public JDBCConnection2()
    	{
    	}
    
    	public static void main(String[] args)
    	{
    	   try
    	   {
    		// Use the standard bridge driver packaged with the jdk
    		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    		
    		//Specify the ODBC data soure name you want to use
    		String sourceURL = "jdbc:odbc:TicketRequest";
    		
    		//get a connection to the database
    		// obtain an instance of the class Connection
    		Connection databaseConnection = DriverManager.getConnection(sourceURL);
    		
    		// IF we get to here, no exceptions was thrown
    		System.out.println("The database connection is " + databaseConnection);
    	   }
    	   catch (ClassNotFoundException cnfe)
    	   {
    		   System.err.println(cnfe);
    	   }
    	   catch(SQLException sqle)
    	   {
    		   System.err.println(sqle);
    	   }
    	}
    }
    Last edited by System_Error; Feb 4th, 2005 at 06:09 AM.

  2. #2
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Re: SQLException being thrown

    TicketRequest should be in your Data Sources (ODBC). Go to Control Panel->Performance and Maintenance->Administrative Tools->Data Sources (ODBC). Click the System DSN Tab->Add. Select the driver and set the Database. Sample of this would be with Access. Click Microsoft Access Driver *.mdb->Finish. Set the Name to TicketRequest and Select the .mdb file of yours->Ok->Ok->Ok. Btw, this is for WinXP.

  3. #3

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: SQLException being thrown

    I'll check it out after school, and let you know if it worked or not.

  4. #4

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: SQLException being thrown

    Quote Originally Posted by nebulom
    TicketRequest should be in your Data Sources (ODBC). Go to Control Panel->Performance and Maintenance->Administrative Tools->Data Sources (ODBC). Click the System DSN Tab->Add. Select the driver and set the Database. Sample of this would be with Access. Click Microsoft Access Driver *.mdb->Finish. Set the Name to TicketRequest and Select the .mdb file of yours->Ok->Ok->Ok. Btw, this is for WinXP.
    Thank you very much, nebulom. That was a very helpful post, and helped me resolve the error..Really appreciate your help!

Posting Permissions

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



Click Here to Expand Forum to Full Width