Using Applets with JDBC

I am developing a Java app that requires access to a RDBMS. I'm having good success connecting to the DB as a Java app but when I try to run it as an applet, I'm getting the following SQLException error:
"No suitable driver"
I have created a policy file that grants me the required RuntimePermission and PropertyPermission. Any idea what else I'm missing?
Thanks,
PjR

Cannot get a connection to the database. <-- my code
No suitable driver <-- SQLException.getMessage()
Exception occurred during event dispatching: <-- stackTrace
java.lang.NullPointerException
at DbaApplet.actionPerformed(DbaApplet.java:76)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:14
50)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1504)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:378)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:216)
at java.awt.Component.processMouseEvent(Component.java:3717)
at java.awt.Component.processEvent(Component.java:3546)
at java.awt.Container.processEvent(Container.java:1164)
at java.awt.Component.dispatchEventImpl(Component.java:2595)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1200)
at java.awt.Component.dispatchEvent(Component.java:2499)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:319)
at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:10
3)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)

Similar Messages

  • Help creating a login applet with JDBC

    Hi, I'm trying to create a login applet using a table from a database (created with Microsoft Access). The bottom line is that I have very little knowledge of ActionListeners. I do know some things about JDBC, but most of it is through notes and lots of reading. I was wondering how to go about looking through a table (with two columns, user and password), to see if it matches what is typed into a JTextField and a JPasswordField. Just a sample piece of code would be helpful. Thank you very much in advanced. Also, I have the GUI done for what I need, just no ActionListeners or JDBC functionality implemented. Here it is:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    public class login extends JFrame /*implements ActionListener*/ {
         private Container container;
         private GridBagLayout layout;
         private GridBagConstraints gbc;
         public login()
              super("Login");
              setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            setSize(300,130);
            setLocationRelativeTo(null);
              container = getContentPane();
              layout = new GridBagLayout();
              container.setLayout(layout);
              gbc = new GridBagConstraints();
              labelUser = new JLabel("Username:");
              gbc.insets = new Insets(2,2,2,2);
              container.add(labelUser, gbc);
              textUser = new JTextField(15);
              gbc.gridx = 1;
              gbc.gridwidth = 3;
              container.add(textUser, gbc);
              labelPassword = new JLabel("Password:");
              gbc.gridy = 1;
              gbc.gridx = 0;
              gbc.gridwidth = 1;
              container.add(labelPassword, gbc);
              textPassword = new JPasswordField(15);
              gbc.gridx = 1;
              gbc.gridwidth = 3;
              container.add(textPassword, gbc);
              button1 = new JButton("Login");
              gbc.gridy = 2;
              gbc.gridx = 1;
              gbc.gridwidth = 1;
              container.add(button1, gbc);
              button2 = new JButton("Cancel");
              gbc.gridx = 2;
              container.add(button2, gbc);
         public static void main(String args[]) {
            new login().setVisible(true);
        private JButton button1, button2;
        private JLabel labelUser, labelPassword;
        private JTextField textUser;
        private JPasswordField textPassword;
    }Thank you again in advanced.

    Sir,
    Much of your question makes middling sense to me. You say applet but you have JFrame for example. I would caution you right now an applet with access for a DB is asking for trouble. Never minding the various security issues Access is not really intended for this sort of operation.
    Now none of that actually seems to be your question but I just thought I'd address that before you go too far down a road fraught with peril.
    As far as what I think you are asking assuming our table looks like this.
    tblUser
    username VARCHAR (access text field) primary key
    password VARCHAR (again known in access as text)then the code would look something like this...
    Connection c; //create your connection
    PreparedStatement ps = c.prepareStatement("SELECT username FROM tblUser WHERE username=? AND password=?");
    ps.setString(1,usernameVariable);
    ps.setString(2,passwordVariable);
    ResultSet rs = ps.executeQuery();
    if(rs.next()){
      // login successful
    }else{
      // login failed!
    rs.close();
    ps.close();
    c.close();Also duffymo will be unhappy if I don't mention that you will really want to give second thought to mixing your database code with your GUI code. Please take a gander through http://java.sun.com/blueprints/patterns/MVC.html
    Sincerely,
    Slappy

  • ORA-03115 Error using CLOB with JDBC

    When I try to access CLOB field data with JDBC driver, I gets following error:
    ORA-03115: unsupported network datatype or representation.
    I am using JDBC 8.1.6(Thin), Oracle 8.0.5
    on Linux OS.
    what's the problem ?
    Thank you for any help.
    Taesoo.
    null

    if it is a bug, then its better to upgrade the database to 10.2.0.4. it is the stable verion in 10g.

  • Using OS_ROLES with JDBC Driver

    I can't get my JDBC connections to pick-up the OS ROLES I have configured. Does the OCI driver support OS Roles?
    I'm using 10gR2 with latest JDBC drivers, running on Windows XP.
    If I connect locally with sqlplus then the roles are established correctly. However, establishing the 'equivalent' connection from Java yields a user with no ROLEs defined, i.e. they are not being picked-up from the OS.
    Is there a trick or is it not supported?
    I believe I have the database and the OS groups setup correctly and, as I say, it works fine with a sqlplus connection.
    If anyone either knows how to do, or knows that its not supported then please let me know.
    Thanks,
    Richard.

    to my knowledge this is not supported in jdbc specification2.0 and 3.0 and jdbc drivers are complied to this standards.
    connecting with sql client is entirely different with the connection using java thin drivers.
    thanks,
    Ruchir

  • Can we use SQLScripts with jdbc?

    can we use the SQLScripts with jdbc?
    if possible please give some information on that.

    no, Its not possible
    prem

  • Applet with JDBC runs very slow

    I have recently created an applet which I am using to interface with a MS SQL Server 2000 database using JDBC. The server is running W2K Server, and a Tomcat web server.
    There are some performance problems with this application. The volume of data being demanded by the database is very low, yet it runs very slow. More specifically, however, the application runs at a very fast pace for several seconds, then "stalls" for 10 -15 seconds.
    The stalling of the application does not take place at the same place in the code all the time; rather it seems to be completely independent of what I am doing. Sometimes a particular operation takes 20 seconds to complete, but the next day the same thing only takes 20msec.
    Any ideas?
    Thanks

    sounds like network usage issues
    hard to tell with no code and no idea how you're configured

  • How to run an applet with JDBC connectivity on a web browser

    I've created an Applet in Java with SQL connectivity...i.e. it retrieves certain data from a table in SQL and puts in the TextField.....
    Now, the problem is that this Applet works in NETBEANS....but fails to work when I use a web-browser..or the "appletviewer" command....
    It says that it doesn't have permission to access local files....On Research, i've found that it is somethin' related to the concept of "Signed Applets", "Permissions" & "Security Policies" in java which doesn't allow any applet (without Certificate) to access Local Files.....
    Can Somebody please tell how to overcome this problem.....?

    I'm going to be blunt with you. You are most likely going to have to redesign your application from scratch. And if it turns out you don't have to then you should anyway because it's a bad idea and fraught with peril.
    Anyway here the major touchpoints on this discussion. You can be the judge of how these various points apply to you.
    - Applets are restricted. - Yes Applets have a number of security restrictions on what they can or cannot do. This is designed to protect users from malicious applets. By signing your applet you can request permission from the user to do certain activities that are otherwise restricted. But not all.
    - If you are using the JDBC-ODBC bridge then you need a different driver. If you sign your applet it might work in some limited scenarios but it will be hairy and is discouraged.
    - If you are using Access or another file based database (CSV Excel etc) then you are doomed. You'll have to get yourself a different database. A non file based one. It doesn't matter if you sign your applet or not. You're still doomed.
    - If you are trying to connect to a database server that is not at the same physical address as your web server you are doomed. Signing the applet will not help
    - Connecting directly to a database from an applet is extremely risky business. Starting with now anyone can steal your username and password for your database quite easily.
    What you should do in the redesign is put all the database accessing code in a Servlet. This Servlet does not have to be Java, it could be PHP, Perl, ASP, etc. It doesn't matter. Just put it on the server side. Then have your applet connect to this code via a webservice to do what is required.

  • How to use setCLOB with JDBC.

    Hi,
    from oracle jdbc document, i know how to use getClob method. but i wonder how to insert a new record included a clob field (setClob). but clob is an interface.
    it seem that it can not be successful to use setclob directly.
    my friend has a way : insert an empty clob into database, then seek this record, and update it with full info again.
    please help me!
    thank in advance.
    wu jianhua.

    A few ways:
    1. Use the LOBs got from a ResultSet, for example,
    Clob x = rs.getClob(1); //you get an oracle.sql.CLOB object
    pstmt.setClob(1, x);
    2. use oracle.sql.CLOB
    public static CLOB empty_lob() throws SQLException;
    creates an empty lob.
    public static BLOB createTemporary(Connection conn, boolean isCached, int
    duration);
    creates temp lob.
    Those methods create object of type oracle.sql.CLOB.
    refer to Oracle jdbc doc for this.

  • Problam using RMI with JDBC

    hi all
    I have build a server & client that work on RMI
    when i try to retrive the data from a DB using JDBC:ODBC i have a premission Error
    can any one help me with it
    one Eyed willy

    When you start Remote object, you need to provide codebase and policy like below:
    java -Djava.rmiserver.codebase=http://myhost/..../ -Djava.security.policy=policy RemoteObject
    your policy file is like
    grant
    // Allow everything for now
    permission java.security.AllPermission;
    // allows anyone to listen on un-privileged ports
    permission java.net.SocketPermission "*:1024-65535", "listen,accept,connect";
    please refer to www.java.sun.com/j2se/1.4.2/docs/guide/rmi/codebase.html
    Hope help you.
    Aung.

  • Using JCheckBox/JComboBox with JDBC

    hello.
    i was just wondering does any of you have links to web pages that include tutorials (and source code) on using JCheckBox with JDBC. would any of you who have experience with using JCheckBox and JDBC together be able to give me a few tips on how to select certain data from a table using JCheckBox and JButton? (examples of such data could be CD/DVD/Game data - i want users of my video library system to be able to view CD/DVD/Game information by name, age category, type and year)
    thank you very much for your help.

    hello.
    Thanks for the replies. I�m wondering do any of you
    have links to web pages that include tutorials and
    source code on using JCheckBox, JButton and JTextArea
    with JDBC. Wow, another person who's never heard of Google. Amazing!
    would any of you who have experience with
    using JCheckBox, JButton, JTextArea and JDBC together
    be able to give me a few tips on how to select
    certain data from a table using JCheckBox + JButton
    and display the data in a JTextArea? examples of such
    data could be CD/DVD/Game data - i want users of my
    video library system to be able to view CD/DVD/Game
    information by name, age category, type and year.
    Users should be able to click on a check box (e.g.
    view by name, age category, type or year) and press a
    button. What would happen then is that data would
    appear in the text area (which could be placed
    beneath the check box + button inside a frame).
    thanks for the help.Find the tutorials, go through them, then come back here when you have a specific problem you need help with. Yes we have experience in these areas, but we're not going to post links and code here just because you're too lazy to use Google and find it yourself.

  • Upgrade 10G to use 10G thin jdbc drivers- OCI

    This is wierd...
    If I upgrade 10G app server to use the 10G thin JDBC drivers, and set up a data source to use the thin drivers, is there any way that I could score a[b] ORA-01010 invalid OCI operation error when I'm not using an OCI driver?
    Anyone else seen this...again, it makes no sense...

    You can not and should not use JDK 1.2 with 8i drivers.
    If you want to use JDK 1.2 drivers, download the 8.1.6 SDK
    from external site.
    Please, please, please READ the FAQ at www.oracle.com/java/jdbc
    before posting
    Premal Mehta (guest) wrote:
    : Hi,
    : Sorry for multiple posting. Previous posting has incomplete
    : information. Here's the whole scenerio...
    : I have Oracle 8i installed on my server. I have downloaded
    : JDBC drivers for Oracle 8i from Oracle site. When I try to run
    a
    : sample example from the demo files given, I get a Windows
    : internal Error "Exception: Access Violation (0xc0000005),
    : Address: 0x6ee0fb83". I am using Oracle 8i on Win NT 4.0 with
    : SP4, IIS4.0 with 128 MB RAM.
    : Also, I am trying to use OCI8 JDBC drivers with JDK 1.2. The
    : classpath is set for classes111.zip files.
    : I am unable to run applets with JDBC also. On using thin
    : drivers, it gives "SO Exception" error.
    : I have tried many options but it dosent seem to work.
    Please
    : help as this is very urgent.
    Oracle Technology Network
    http://technet.oracle.com
    null

  • Help needed with JDBC - please help! (newbie)

    hi all
    i m new to jdbc
    i have installed MySQL server on my winxp machine
    i used the command:
    mysql -p -u root
    Enter password: ****now when writing a prog i m getting a prob at this piece of code:
    Connection con=DriverManager.getConnection("jdbc:odbc:books","root","root");wot is wrong wid this code?
    please help......
    thanks in advance

    There are about 20 different things that could be wrong a this point; I'm not going to list them all. If you want specific help, you need to post specific information. This is usually done by posting either a stack trace from an exception, or a more complete section of code and a description of the problem and ALL the symptoms. You have all the information on what you've done, we have none of it.
    Instead of trying to diagnose whats wrong with your ODBC setup, I'm going to give you some strong advice; don't use ODBC with JDBC if you can avoid it, and with MySQL you can avoid it. It makes things simpler, less can go wrong, and you don't have to configure a DSN on every machine that you install the program on.
    To use "pure" JDBC without ODBC for MySQl:
    1) download the JDBC driver (you might already have this)
    http://dev.mysql.com/downloads/connector/j/3.1.html
    2) follow the installation instructions
    http://dev.mysql.com/doc/refman/5.0/en/java-connector.html
    In particular, make sure your classpath is set correctly
    3) Here's an example of loading the driver and establishing a connection
    http://dev.mysql.com/doc/refman/5.0/en/cj-connect-with-drivermanager.html
    Note the form of the connection URL,
    "jdbc:mysql://localhost/test?user=monty&password=greatsqldb"
    This is what an URL without ODBC looks like; there is no DSN, which means no DSN has to be configured.
    4) The MySQL database has some built-in security, to prevent malicious connections from outside computers. Solutions to that and other common problems are here:
    http://dev.mysql.com/doc/refman/5.0/en/cj-faq.html

  • Using applets

    I have a web application that contains a servlet, applet, jsps, html, etc. The applet classes are
    packaged in a jar file in the <web app root>/classes directory. On the root, I have an html page
    that is supposed to access the applet. Any time I go to this page, the applet classes cannot be
    found. I'm using the same web app on a different application server, and everything works fine. Has
    anyone been able to use applets with WebLogic?
    Here is my html code for displaying the applet...
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = 100% HEIGHT = 100%
    codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
    <PARAM NAME=CODE VALUE = "com.mxi.mx.expeditor.applet.ExpeditorApplet" >
    <PARAM NAME=ARCHIVE VALUE = "ExpeditorApplet.jar" >
    <PARAM NAME="codebase" VALUE = "classes/" >
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
    </OBJECT>
    </BODY>
    Josh Cimino
    Software Developer
    Mxi Technologies Ltd.
    1430 Blair Place, Suite 800
    Ottawa, ON, Canada
    K1J 9N2
    E: [email protected]
    T: 613.747.4698 ext 479
    F: 613.747.1909
    www.mxi.com
    "From the flight line to the bottom line"
    [att1.html]

    I hope I'm making at least some sense here. The classes extending Applet are to be shown in a web browser, embedded on the page. A class with nothing but a main-method would traditionally be a command-line application. Extending Frame results in a stand-alone application with a visible window, a GUI. They are all correct, it just depends on what you want to create.

  • Problem: connect DB with Applet by JDBC-ODBC bridge

    Dear all,
    When I connect local MS SQL server by "sun.jdbc.odbc.JdbcOdbcDriver" as below, it works well! However, when I put the similar code under Java Applet program, it cannot run by showing error:
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1501)
    at sun.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:169)
    I think Java Applet has some security policy when I try to use applet to connect(read/write) DB. How can I solve it so that I can browse my applet under IE.
    Thanks a lot!
    Here is my worked code in Java program but not in Applet:
    import java.sql.*;
    public class TestJDBC1 {
    public static void main(String args[]) throws Exception {
    String userid = "";
    String password = "";
    // Register the driver with DriverManager
    new sun.jdbc.odbc.JdbcOdbcDriver();
    // Get a connection
    Connection conn = DriverManager.getConnection("jdbc:odbc:rdr",
    userid, password);
    // Create a statement for executing SQL
    Statement stmt = conn.createStatement();
    // Execute a query / SELECT statement
    ResultSet rset = stmt.executeQuery("SELECT * FROM PlatformNode");
    ResultSetMetaData rsmd = rset.getMetaData();
    // Find out how many columns were returned by the query
    int count = rsmd.getColumnCount();
    // Loop until all rows have been processed
    while (rset.next()) {
    // Loop until all columns in current row have been processed
    for (int i = 1; i <= count; i++) {
    // Print out the current value
    System.out.print(rset.getObject(i));
    // Put a comma between each value
    if (i < count) {
    System.out.println(",");
    // Start the next row's values on a new line
    System.out.println("");
    // Close the database objects
    rset.close();
    stmt.close();
    conn.close();

    Hi,
    Applets by default are restricted from accessing a lot of things.to enable applest from accessing database and other thngs u need to edit the policy file
    Try this.
    go to the jre/bin directory open the policytool.exe file
    and add permission(in ur case RuntimePermission to access class in package sun.jdbc.odbc) and save the file.
    this will enable applets from accessing the databse.
    Hope that helps
    Note:
    policytool.exe must be used to open the java.policy file present in /jre/lib/security directory and then add the permissions
    regards,
    Partha

  • Problems: connect DB with Applet by JDBC-ODBC bridge

    Dear all,
    When I connect local MS SQL server by "sun.jdbc.odbc.JdbcOdbcDriver" as below, it works well! However, when I put the similar code under Java Applet program, it cannot run by showing error:
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1501)
    at sun.applet.AppletSecurity.checkPackageAccess(AppletSecurity.java:169)
    I think Java Applet has some security policy when I try to use applet to connect(read/write) DB. How can I solve it so that I can browse my applet under IE.
    Thanks a lot!
    Here is my worked code in Java program but not in Applet:
    import java.sql.*;
    public class TestJDBC1 {
    public static void main(String args[]) throws Exception {
    String userid = "";
    String password = "";
    // Register the driver with DriverManager
    new sun.jdbc.odbc.JdbcOdbcDriver();
    // Get a connection
    Connection conn = DriverManager.getConnection("jdbc:odbc:rdr",
    userid, password);
    // Create a statement for executing SQL
    Statement stmt = conn.createStatement();
    // Execute a query / SELECT statement
    ResultSet rset = stmt.executeQuery("SELECT * FROM PlatformNode");
    ResultSetMetaData rsmd = rset.getMetaData();
    // Find out how many columns were returned by the query
    int count = rsmd.getColumnCount();
    // Loop until all rows have been processed
    while (rset.next()) {
    // Loop until all columns in current row have been processed
    for (int i = 1; i <= count; i++) {
    // Print out the current value
    System.out.print(rset.getObject(i));
    // Put a comma between each value
    if (i < count) {
    System.out.println(",");
    // Start the next row's values on a new line
    System.out.println("");
    // Close the database objects
    rset.close();
    stmt.close();
    conn.close();

    ur question has just been answered under the java programming section

Maybe you are looking for

  • How to upgrade Windows 7 64 bit to windows 8.1 ?

    Hello, I have HP Notebook PC which i purchased as DOS based machine before 5 months. Currently i have windows 7 64 bit version operating system. Now i want to upgrade my laptop with windows 8.1 operating system. So how can i upgrade my windows 7 64 b

  • I'm running OS X, but I can't run Final Cut Pro 1.0 and appropriate upgrade

    I recently purchased a Macbook with OS 10.4.6 on it. I have Final Cut Pro 3, but I can only install it via FCP1 and upgrade to FCP2 and finally to FCP3. However, when I try to install 1.0, it says that this system cannot support it. I can't seem to f

  • PowerMac 7300 Problems: Browser, Accessing Hotmail, Freezing

    We have an ancient PowerMac 7300, with a G3 500Mhz upgrade. I know that some people will tell us to simply get a new(er) computer, but that is not an option right now. We are having problems accessing many websites, including Hotmail, which we use a

  • SRM with PPS = Extended Classic Scenario

    Does SRM Procurement for Public Sector (PPS) require Extended Classic Scenario? If so, could some one refer me to an official documentation that states such? Thanks.

  • Facetime the volume is too loud

    I just updated my iPod touch to iOS 6 and when I  Facetime the volume is too loud even if I turn it down. I tried to restore it several times but nothing changed...what can I do? Do I have to send it to Apple support?