• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC Error

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic