File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes JDBC Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC Error" Watch "JDBC Error" New topic
Author

JDBC Error

Patrick Mugabe
Ranch Hand

Joined: Jan 08, 2002
Posts: 132
I have the written the following code:
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class ProjTest extends JApplet implements ActionListener
{
JButton btOK;
Connection con;
Statement stat;
String url = "jdbc dbc rojTest";
String data = "Insert into Emp_Details " +
"Values('Patrick', 'Mugabe', 'E231', 'Programmer')";
public void init()
{
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
btOK = new JButton("Click");
cp.add(btOK);
btOK.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception ex)
{
getAppletContext().showStatus("Error on connection" +
ex.getMessage());
}
try
{
Connection con = DriverManager.getConnection(url, "", "");
stat = con.createStatement();
stat.executeUpdate(data);
}
catch(SQLException conex)
{
showStatus("Error reported " + conex.getMessage());
}
catch(Exception exc)
{
showStatus("check for data errors"); }
}
}
When I click the button (btOK) to insert data into my database, I am getting the following error:
Error reported No suitable driver.
Please help me on how I can overcome this error.
Patrick Mugabe
Ranch Hand

Joined: Jan 08, 2002
Posts: 132
I figured that it was a problem to do with permissions so I resolved it using policyTool.
HOWEVER, I STILL HAVE ANOTHER PROBLEM. I am still getting an error if I use Internet Explorer but I have no problems when I use Appletviewer.
How can I solve this problem.
HanMing Low
Ranch Hand

Joined: Oct 18, 2001
Posts: 196
Hi,
Are you trying to use an applet download from a web server and connect to a MySQL on localhost or other than the web server?
In that case, you need more security setting other than policy tool.
Have you configure the cert?
You can refer to this article
http://developer.java.sun.com/developer/technicalArticles/Security/Signed/index.html
Not exactly the same, but you need the same type of configuration for access in Applet.
Hope it helps.
Cheers.

Han Ming
Patrick Mugabe
Ranch Hand

Joined: Jan 08, 2002
Posts: 132
Thanks a lot for the advise. It's different from what i wanted but close and very helpful. I think it will help me in getting over this problem.
Thanks a lot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC Error