Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Joel Elliott   on Oct 10 In Java Category.

  
Question Answered By: Teresa Rogers   on Oct 10

I am trying to write  a connection  class to be able to connect  to a data  sourcr
however I
keep getting this error
"connection.java": unreported exception  java.lang.ClassNotFoundException; must
be
caught or declared to be thrown at line  25, column  13
When I code  the connection in the interface  and use a button  to connect I have
no
problems and cannot find  an answer.
Here is my class. The error  is in the line Class.forName(driver);
I appreciate any help  I can get.

package database_application;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

// the original framework
// the event handler
import java.sql.*; // sql objects
import javax.swing.*; // the new widgets and components
import java.awt.*;

public class  connection {
public connection() {
}

public void connect() {
try {
String driver = "com.borland.datastore.jdbc.DataStoreDriver";
Class.forName(driver);
String conn_string =
"jdbc:borland:dslocal:/Developer/Applications/JBuilderX/
JBuilder.framework/samples/JDataStore/datastores/employee.jds";
Connection db_connection = DriverManager.getConnection(conn_string,
"duncan", "");

}
catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "There has been an" +
" error connecting " + ex.toString(),
"Connection Error",
JOptionPane.YES_NO_OPTION);
}
}

}

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Calling classes Or get search suggestion and latest updates.


Tagged: