I am new to java. I have written an application which works just fine but when I package it into a jar file it fails when trying to connect to the database(see below) with SQLException no suitable driver found for jdbc.oracle.thin......... Any help appreciated.
package as400;
import java.sql.*;
import oracle.sql.CLOB;
import java.io.*;
import java.util.*;
public class DBAccess
{
private static Connection connection;
public static void connect(String server, String database, String userName, String password)
{
connect(server, database, userName, password, "1521");
}
public static void connect(String server, String database, String userName, String password, String port)
{
registerOracleDriver();
try
{
String dbString = "jdbcracle:thin" + server + ":" + port + ":" + database;
connection = DriverManager.getConnection(dbString, userName, password);
}
catch (SQLException e)
{
e.printStackTrace();
}
}
private static void registerOracleDriver()
{
try
{
Class.forName("oracle.jdbc.OracleDriver");
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}
package as400;
import java.sql.*;
import oracle.sql.CLOB;
import java.io.*;
import java.util.*;
public class DBAccess
{
private static Connection connection;
public static void connect(String server, String database, String userName, String password)
{
connect(server, database, userName, password, "1521");
}
public static void connect(String server, String database, String userName, String password, String port)
{
registerOracleDriver();
try
{
String dbString = "jdbcracle:thin" + server + ":" + port + ":" + database;
connection = DriverManager.getConnection(dbString, userName, password);
}
catch (SQLException e)
{
e.printStackTrace();
}
}
private static void registerOracleDriver()
{
try
{
Class.forName("oracle.jdbc.OracleDriver");
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
}