Applet to database

hi!
i got a question concerning database access from within a browser somewhere on the inet.
i'm playing around with apache, mysql and such things. now i wanted to make an applet which connects to a database.
1) if my applet is decompiled, then anyone can see mysql user + password, right?
2) granting a java application access to a database requires classpath to include the path to the connector.
how about applets, since (imho) there is no option to set classpath for an applet.
3) as i read, applets will create connections for each client, opening the site.
so what solution is better? servlets? something else?
i am new to these things so any links to gentle intro stuff for your propositions would be great.
thanx in advance for any answers
smalls

1) if my applet is decompiled, then anyone can see mysql user + password, right?Yeah.
2) granting a java application access to a database requires classpath to> include the path to the connector.
how about applets, since (imho) there is no option to set classpath for an applet.Your applet jar should Include that JDBC driver pacakage, or use <PARAM NAME = ARCHIVE VALUE = "../../yourJDBCDriver.jar" parameter.
3) as i read, applets will create connections for each client, opening the site.
so what solution is better? servlets? something else?You should consider to use servlet or jsp. Of course, you can use applet if you need many GUI.

Similar Messages

  • Connect applet to database using JDBC

    I try to connect Applet to database, but have error:
    Access denied (Java.lang.Runtime.Permission access Class In paclage.sun.jdbc.odbc)
    I think the reason is the security issue, but how to implement the security issue in the code?
    Help me...

    If you aren't using the plugin, changing the policy file for the Java Runtime Environment (JRE) won't do anything. Changing the policy file and signing the applet are two ways of granting an applet permission. I only use changing the policy file for testing purposes. I broke down and bought a certificate after I realized I would have to change the policy file on hundreds of machines, and do it again if the server changed.
    You sound like you should be using the plugin. Appletviewer knows about the JRE and uses it. You need to change your HTML to use EMBED and OBJECT tags instead of APPLET tags (use HTMLConverter).
    sun.jdbc.obdc.JdbcOdbcDriver is in rt.jar, which is in /Prog Files/Javasoft/JRE/1.3???/lib and is installed when the pluggin is installed (which happens automagically when using the EMBED and OBJECT tags). It was also loaded on your development machine when you installed the SDK.
    You can remove the need to sign the applet to test whether this is a security problem or machine configuration problem. If you copy the .html and .class files to a directory on a machine you expect it to run on, start your browser and type 'C:\MyDirectory\MyApplet.html' in the address bar. Applets loaded locally are granted all permissions.

  • Applet + remote database + newbie

    Hi,
    Tired of microsoft randomly dumping the market making me rewrite applications each time they publish updated os,language etc...i finally (and really happily) surrender to java....
    Here is my point : i'd like to create applet-based application that will retrieve-update from/to remote server, (access database for instance)...am i pointing the worng direction or does it seem a good choice.
    Is it necessary to use servlets ? (all i've seen about applet-servlets seems a bit confusing even though it seems the right way to build solid rock applications, actually, i could begin with applets and remote database and later go to an applet-servlet application)
    Any good suggestion is welcome, but, please ,don't tell me about .net

    You can make a database connection via an Applet or an Servlet. You can make a database connection via Applet - Servlet - Database also.
    Making db connecion using applets or servlets is easy task.
    Visit the site's applet section to have an example. Since you are a beginner, it might look like a nightmare ;-)
    Hope it helps
    Uma
    http://www.javagalaxy.com

  • Connecting an applet to database

    Hello Everybody,
    I have a problem of connecting the applet to the database through a separate java class.
    to be more clear i have a applet which uses a java class file for databse conenction.
    the error i'm facing while doing this is that java.net.socket permission.
    my database is oracle and i'm using thin driver to establish the connection.
    now i have the doubt that is it the right kind of approach.
    i mean can i connect the applet to the database through a normal java class.
    i hope some can get me the solution.
    thanking u in advance
    regards
    RaviTeja

    I suppose your problem is that you get a Security Exception when your applet try to open a JDBC connection to a database located on another server, right?
    To solve the problem, you have to sign your applet with a digital signature or bring the webserver and the database on the same machine.
    (Concerning the digital signatures, look in the forums, and you will find tons of messages about it)

  • Applet / SQL Database communication

    I am developing an applet that needs to connect to a SQL Database to keep track of a variety of information. I am running into some errors when I try to connect to the database.
    Can anyone tell me the best way for an applet to connect to a SQL database without editing the client's policy file to give permission?
    Any help with this matter would be much appreciated.
    Thanks.

    I am developing an applet that needs to connect to a
    SQL Database to keep track of a variety of
    information. I am running into some errors when I
    try to connect to the database.
    Can anyone tell me the best way for an applet to
    connect to a SQL database without editing the
    client's policy file to give permission?
    Any help with this matter would be much appreciated.
    Thanks.The best way to communicate to the database from an applet is through a servlet. But if you seriously want anybody to decompile your applet code and really fry your db its upto you. I wouldnot communicate directly from an applet to a db its not worthwhile

  • Applets with databases

    I have a problem with an application done with applets in Java that is connected to a data base in Oracle, the problem is that when I execute the applet in a navigator to not it gives back the consultations me that assume must make…. as I solve this?
    Please help me....

    Claudia,
    your aren't to speficic about what kind of error occurs. Do you simply get nothing in return, hangs the request, or is the request aborted with an exception?
    If you use the Java Plugin (part of Sun's Java JDK), you can open the Java console and watch, whether you get an exception or not.
    Which Oracle driver do you use (thin or OCI) ? And which version do you use ? Does the request work well in an application (i.e. not runing in an applet context) ?
    Is the database server located on the same machine as the web server, from which you download your applet ?
    Best,
    Manfred

  • Error when connecting applet to database

    Hi,
    I'm trying to make an applet that get data from database.
    I'm using this code to connect to database :
    try
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydatabase","mypassword", "password");
    System.out.println("inside of connection");
         if(!con.isClosed())
              System.out.println("Successfully connected to MySQL server...");
              Statement st = con.createStatement();
              ResultSet s = st.executeQuery("SELECT myString FROM string");
                        while (s.next())
                             ad = s.getString("myString");
                             System.out.println(ad);
              catch(Exception e)
                   System.err.println("Exception: " + e.getMessage());
    It shows me error like this :
    java.lang.ExceptionInInitializerError
         at com.mysql.jdbc.Connection.<init>(Connection.java:1174)
         at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:264)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at java.sql.DriverManager.getConnection(Unknown Source)
         at com.inulsc.newsticker.connection.getString(connection.java:26)
         at com.inulsc.newsticker.NewsTicker.readFromDatabase(NewsTicker.java:481)
         at com.inulsc.newsticker.NewsTicker.init(NewsTicker.java:239)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.RuntimeException: Unable to initialize character set mapping tables
         at com.mysql.jdbc.CharsetMapping.<clinit>(CharsetMapping.java:73)
         ... 9 more
    I'm using Tomcat and I have copymysql-connector-java-3.1.13-bin download to C:\Tomcat 5.5\common\lib.
    Any one can help me please? I really need to solve this problem.
    I will appreciate any answer.
    Thanks,
    Vijay

    Thanks for you answer Jos, but honestly I don't know what I should do then, since I can't get data from database through the applet.
    I have read some articles that we can get data from database through the applet (they use tomcat too). I have followed what the article said, but I still get the error.
    Do you have any idea Jos? Thank you very much for your nice attention
    Warmnest regards,
    Vijay

  • Connecting applet to database

    hi guyz!, plz help me
    im working wid an applet and i need to connect it to a databse.
    while doing so i got this error:java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.jdbc.odbc)
    based on sum topics i read on net i even changed my java policy as follows,but it didnt help:
    permission java.lang.RuntimePermission "accessClassInPackage.sun.jdbc.odbc";
    permission java.util.PropertyPermission "file.encoding", "read";
    plz provide me wid a solution as my project is stuck,Thanks in advance!

    There is a difference on what you can do in the init() method and in methods callable from javascript. Methods callable from javascript simply is not thrusted. So you can start a thread from the init method which connects to the database and wait for variables set by javascript to change, for instance SQL parameters. Then the thread executes the SQL to the database and returns result to web page. Of course the jar containing the applet has to be signed, but thats what this forum is about.
    Actually it seems better to make an ordinary request to the webserver and put the result in an IFRAME which calls a javascript function.
    Erik

  • Connect applet to database!

    How i can connect a client applet to my database on server?
    Where i can get a source code about this?
    PLEASE HELP ME!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    I hope you can help me!
    Sorry my bad english, please...

    Try this link:
    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=&qt=applet+JDBC+-%22Replies%3A+0%22

  • Applet - Servlet - Database - Servlet- Applet

    Hi All,
    I am using Oracle8i and IE 5.0. I am trying to retrieve the data from a db table and display it.
    Sequence is as following:
    1. Query passed to the applet.
    2. Servlet excutes this query using JDBC and returns the resultset to applet.
    3. Applet displaysthe results.
    Is there anybody who has a code sample to do this, my id is [email protected] ? I am totally new to java and servlets. I would really appreciate any help.
    Thanks a lot.
    Manuriti
    [email protected]

    I've never dealt with the code to handle the applet portion of what you're trying to do, but I can help you with the servlet stuff.
    Your servlet should contain code to accomplish the following steps:
    1. Load an Oracle JDBC driver into memory.
    2. Open a JDBC connection to the Oracle database.
    3. Create a JDBC Statement object which contains the appropriate Oracle SQL code.
    4. Execute the Statement object, which will return a ResultSet.
    5. Read the ResultSet data.
    6. Pool or close the Statement and Connection objects.
    All of these steps are simple. Here's what they might look like in practice:
    // load the Oracle driver
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // open the connection
    String cs = "jdbc:oracle:[email protected]:1521:DBNAME"; // connection string
    String userName = "scott";
    String password = "tiger";
    Connection con = DriverManager.getConnection(cs, userName, password);
    // create a Statement object
    Statement stmt = con.createStatement();
    // create a ResultSet object
    ResultSet rs = stmt.executeQuery("select * from DUAL"); // your SQL here
    // INSERT CODE HERE TO READ DATA FROM THE RESULTSET
    // close the Statement object
    stmt.close();
    // close the Connection object
    con.close();
    So that's how you get data from your Oracle database. Now, how do you pass it to your applet? Well, this is hardly trivial. Typically, servlets return an HTML-formatted text stream. It is possible to have an applet communicate with a servlet, but that raises security issues that I don't fully understand. I believe you would have to have your user's browsers set to the lowest possible security settings, otherwise the browser won't let the applet open a socket to a foreign IP, but again, I'm shaky on that one.
    Anywho, let me know if this was of help and if you have more questions on the servlet/applet stuff. I can probably help you with more specific questions,.

  • Applet And Database

    Hi;
    Can i do database connectivity through applet if your answer is no then plz give me reasons why?
    thanks

    Hi,
    Can i do database connectivity through applet?Applets loaded over the network are subject to various security restrictions. Although this can seem bothersome at times, it is absolutely necessary for network security, and security is one of the major advantages of using the Java programming language. An applet cannot make network connections except to the host it came from unless the browser allows it. Whether one is able to treat locally installed applets as "trusted" also depends on the security restrictions imposed by the browser. An applet cannot ordinarily read or write files on the host that is executing it, and it cannot load libraries or define native methods.
    Applets can usually make network connections to the host they came from, so they can work very well on intranets.
    The JDBC-ODBC Bridge driver is a somewhat special case. It can be used quite successfully for intranet access, but it requires that ODBC, the bridge, the bridge native library, and JDBC be installed on every client. With this configuration, intranet access works from Java applications and from trusted applets. However, since the bridge requires special client configuration, it is not practical to run applets on the Internet with the JDBC-ODBC Bridge driver. Note that this is a limitation of the JDBC-ODBC Bridge, not of JDBC.
    With a pure Java JDBC driver, you do not need any special configuration to run applets on the Internet.
    Hope this helps.
    Good Luck.
    Gayam.Srinivasa Reddy
    Developer Technical Support
    Sun Micro Systems
    http://www.sun.com/developers/support

  • Applets and Databases....

    Hi all,
    thanks in advance for any subsequent posts.
    I was wondering if anyone could tell me if you use an applete to interact with a database. I have read some tutorials on this and I am confused by them. I have some classes set up to allow for connection to a mysql database, but was wanting to use an applete as apposed to a small program to start this off. At the moment I am getting a:
    java.net.SocketException
    MESSAGE: java.security.AccessControlException: access denied(java.net.SocketPermission 127.0.0.1:3306 connect, resolve
    I am trying to connect to a Mysql database on the same system that I am trying to run the applete on.
    thanks for all posts,
    Mark.
    Message was edited by:
    Marky_boy

    Appologies all, found the answer is another post. I will try signing my applete...
    ..thanks again,
    Marky Boy...

  • Something about applet and database?

    applet cant write and read from outer files.
    but can it read from database?if i don't modify my security policies.

    zhangv,
    We hava a web application with an applet in it that communicates with the server over HTTP. So, you need not worry about security. We use a multi-tiered environment. That is, the middle layer uses an application server (Sybase EAServer) and the backend layer is our database (Sybase ASE 12.5). Our application server fetches the data from the database and streams XML to the applet via a servlet. You can find a wonderful example for how this works in an article on Java world, entitled:
    Title: "A J2EE presentation pattern: Applets with servlets and XML"
    Subtitle: "Enhance your Web interfaces with powerful XML-configured applet components"
    http://www.javaworld.com/javaworld/jw-05-2002/jw-0524-j2ee.html
    Hope this helps
    TJJ

  • Signed applet and database connetion...

    Hello,
    Well, I am deploying an applet application which needs to connect with a postgres database.
    I put my application in my hosting then I changed my local java.policy file adding a line as
    permission java.net.SocketPermission "127.0.0.1:5432", "connect,resolve";And my applet works... but I don't want that the user needs to change his policies file.
    I read in somewhere in the forum if the applet is signed the user doesn't need to change anything... then I sign the applet. But it doesn't work. It looks to me that signing the applet is not enough to allows the connection.
    But I don't sure.
    Some body had had the same problem or am I doing some thing wrong?? Other Ideas
    By the way, sorry for my bad english, I hope you can understand what I am saying.
    Bye, and thanks by advance

    4NDR01D3 wrote:
    Thanks for the answer.
    That's a good test, I put some code before the DB connection to create a file:
                  File file = new File("tavo.txt");
                 boolean success = file.createNewFile();
                 if (success) {
                      javax.swing.JOptionPane.showMessageDialog(null, "YES");
                     // File did not exist and was created
                 } else {
                      javax.swing.JOptionPane.showMessageDialog(null, "NO");
                     // File already exists
                 }And surprisingly it creates the file. but doesn't connect to the database.
    I Sign the applet by command line, like this:
    keytool -genkey -alias signFiles -keystore compstore -keypass pass -dname "cn=salazar" -storepass pass
    jarsigner -keystore compstore -storepass pass -keypass pass -signedjar Sproceso.jar proceso.jar signFiles
    baftos wrote:Or at least one of the classes that are on the stack when you cpnnect to the database does not come from > the signed jar.Out of the Jar are the JDBC files(postgres.jar), it could be the problem??Your JAR is signed OK and this is good.
    DB connections are not prohibited as such.
    What is prohibited are Socket connections, which DB connections use internally.
    Therefore, if any of the classes on the stack, when the Socket connection occurs
    is not from your jar, it will fail. Therefore, the 3rd party files must be all in your jar.
    Technically, this is easy: explode their jar and create your jar in such a way as to contain
    all the files from their jar as well. Do it just as an experiment. If it works, read well
    their licensing terms, which may forbid this. If they forbid it or if in doubt, contact them.

  • Applets and DataBase Access

    Hello, I want to know if it's posible data base acces from a Applet and how do it. The SQLException: No suitable Error is always in the output.The Applet code is:
    import java.applet.*;
    import java.awt.*;
    import java.util.*;
    import java.sql.*;
    import java.net.*;
    import java.io.*;
    public class CreateCoffees extends Applet
         String url = "jdbc:oracle:thin:@localhost:1521:BD";
    Connection con;
    String createString = "insert into COFFEES " +
    "values('Pepe')";
    Statement stmt;
    TextArea textarea = new TextArea();
    public void init()
    setLayout(null);
         textarea.setBounds (10,50,280,150);
         textarea.setText("Empieza");
         add(textarea);
         try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    } catch(java.lang.ClassNotFoundException e) {
         System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    textarea.setText(e.getMessage());
    try {
    con = DriverManager.getConnection(url, "SYSTEM", "manager");
    stmt = con.createStatement();
    stmt.execute(createString);
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    textarea.setText(ex.getMessage());
    }

    A no suitable driver error means that either your connection string is incorrect or you are not loading the driver (or failing to load it and ignoring the exception.)
    Presumably you have already dealt with the problem of delivering the oracle zip file with your applet?
    And you are not getting the not found exception in your code?

Maybe you are looking for

  • Why do attachment files in excel disapear in apple mail when sent from a PC

    I am trying to get excel files & they dissapear when sent from a PC network

  • User login not starting up but others do

    I have been frustrated by the fact that the main login for my intel mac running snow leopard will not log in, but other user log ins will. The computer will boot to the log in screen, and if I select other users (wife, kids) it logs them in no proble

  • Admin tool problem

    Hi, When i try to deploy a 9MB J2EE application on iAS6.0SP2, the process goes fine, but my iAS Admin tool doesnt work. It gives timeout error. But if the same application's size is cut down to 7MB, the admin tool works fine. Can you please suggest m

  • How to export long formatted text from SAP to an excel Cell

    I have created an object(ZMM_TXT_PD) and an ID(Y01) using se75 transaction. With a Z program a store some lines in STXH table with object ZMM_TXT_PD and ID Y01. These texts are very long and formmated. Now I need another Z program in order to downloa

  • Office- word breaks too often

    everytime I use cut&paste, word stops working and it breaks!!! I have office 2011 in my macbook pro, I think it`s student`s version. I got it for free when I bought the computer and it comes with 3 licenses. I already used the 3 of them, so I`m not s