|
-
Feb 2nd, 2005, 07:42 PM
#1
Thread Starter
Frenzied Member
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.
-
Feb 2nd, 2005, 08:58 PM
#2
Fanatic Member
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.
-
Feb 3rd, 2005, 06:26 AM
#3
Thread Starter
Frenzied Member
Re: SQLException being thrown
I'll check it out after school, and let you know if it worked or not.
-
Feb 3rd, 2005, 06:05 PM
#4
Thread Starter
Frenzied Member
Re: SQLException being thrown
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|