JDBC
Can you tell me what I'm possibly missing here... The database is on a remote server, and I'm trying to connect via my machine:
import java.sql.*;
import javax.swing.*;
/**
* @author administrator
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class connect {
public static void main(String[] args) {
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
// Create a connection to the database
String serverName = "000.000.000.000";
String portNumber = "0000";
String sid = "will";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "uid";
String password = "passwd";
connection = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
// Could not find the database driver
//JOptionPane.showMessageDialog(null, "Could not find the database driver");
System.out.println("Could not find the database driver");
} catch (SQLException e) {
// Could not connect to the database
JOptionPane.showMessageDialog(null, "Could not connect to the database");
}
}
}
What do I need on my machine.
1. Do I need to alter the TNS names?
2. Do I need to have the jave code (application) on the server in-order to execute? Or can I run it from my machine,as long as I have the correct servername,portnumber, sid, etc...
I'm running into my exception handler of "Could not find the database driver"...

