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

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.

  • 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

  • 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

  • How to connect my access database using applet?

    hi all,
    i need to connect my access database in my applet program which should work like an atm machine..I dont know how to connect it. Im new to applet same thing in JDBC application. Please help i terribly need it, our deadline in our case study is fast approaching and i still dont know how to do it. I tried the tutorial but i received some sql exception error. thanks!

    Try this link
    http://java.sun.com/docs/books/tutorial/jdbc/basics/

  • 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 trying to connect to Oracle Database

    Hello!
    I am trying to access an Oracle 8i database from an Applet. The problem is that the following exception is reported in IE 5.5
    and the Applet is not run.
    exception: com.ms.security.SecurityEceptionEx[oracle/net/nt/TcpNTAdpater.connect]:cannot access "pc38"
    (where my database is being hosted on the intranet at a NT workstation called pc38). The applet does not seem to be able to connect to the datase due to security reason).
    In Netscape no exception is shown in the Java Console but the Applet is not run anyway.
    What do I have to do for the Applet to be able to connect to the database. The code for the Applet and the HTML file have been appended to this message.
    Thanx in advance
    Saad
    /*********************************Applet*******************************/
    String serviceName="ora816";
    String hostName="pc38";
    String userName="ipweb355";
    String password="ipweb355";
    String port="1521";
    Connection conn=null;
    try
    java.sql.DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    String url = "jdbc:oracle:thin:@"+this.hostName+":"+this.port+":"+this.serviceName;
    System.out.println("url = "+url+ " UserName = "+this.userName+ " password = "+this.password+" port = "+this.port );
    conn = java.sql.DriverManager.getConnection(url, this.userName, this.password);
    public void paint(Graphics g){
    g.drawString("HI there",20,20);
    try{
    Connection con = conn;
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("Select COUNT(*) AS NUM_ROWS from TABLE_ONE");
    rs.next();
    String temp = rs.getString("NUM_ROWS");
    g.drawString(temp,100,20);
    catch(SQLException e){
    g.drawString(e.getMessage(),20,20);
    /********************HTML*********************************************/
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">
    <TITLE>
    HTML Test Page
    </TITLE>
    </HEAD>
    <BODY>
    testApplet will appear below in a Java enabled browser.<BR>
    <APPLET
    CODEBASE = "D:\IPWeb\Swings\TreeApplet\src"
    ARCHIVE = "classes111.zip"
    CODE = "testApplet.class"
    NAME = "TestApplet"
    WIDTH = 400
    HEIGHT = 300
    HSPACE = 0
    VSPACE = 0
    ALIGN = middle
    >
    </APPLET>
    </BODY>
    </HTML>
    <!--the classes111.zip is being send in the Archive file so that the java.lang.ClassNotFound Exception is not reported-->
    /*********************************************************************/

    Hi!
    Try to add this line to java.policy file on machine that's running applet:
    permission java.security.AllPermission;

  • Connecting to a database over the internet

    Hello ,
    Ok heres an interesting question -
    I would like to have an applet running on my browser which needs to connect to a central server over the internet, which in turn will need to connect to a database and query some results. These results will be stored as flat files within the server.
    At the moment, I have a URL that connects to the database via the
    internet and that is working. However I don't think my applet on my browser will be able to create a flat file on that server direclty.
    Could some one please tell me how to go about this problem?
    Shalini

    Yes, put a servlet in between the applet and database. Let the servlet interace with the database on the applet's behalf and write that file on the server side.
    %

  • Unable to connect to MySQL database

    Hello,
    I have written a DatabaseManager class that controls access to a locally stored database, implemented in mysql. In theory, client request should be passed to the DatabaseManager through RMI, but I cannot even create a connection to the database yet!
    Here's my connect statement:
    con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/media", "mysql", "mysql");When this statement is executed, the following exception is produced:
    java.sql.SQLException: Unable to connect to any hosts due to exception: java.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding read)Can somebody explain to me how I successfully create a connection to the database? I would be extremely grateful. Also, could somebody explain how I could connect to the database from a remote machine using the following connect statement:
    con = DriverManager.getConnection("jdbc:mysql://server:3306/media", "mysql", "mysql");I have a feeling I need to grant a certain PropertyPermission in my policy file, but I'm unsure of what values I should be using.
    Thank you in advance.
    Pete

    Thank you for the prompt reply.
    In answer to you question: No, it is not an applet. The DatabaseManager is a class that implements a Remote interface, I have it running on the same machine as the mysql database (the server). I then have a small GUI that runs on a client machine which is used to make RMI calls to the DatabaseManager across the network in order to query the database.
    When the DatabaseManager object is spawned on the server, it tries to connect to the database to be ready for client queries. This is when it produces the exception mentioned in the original post.
    What confuses me is that in my original implementation, the DatabaseManager object was run on the client and the mysql JDBC had no difficulty in connecting to the database across the network. Could the security manager have something to do with it? I am using the RMISecurityManager in conjunction with the java.policy file from the Java RMI tutorial on the Sun website.
    Pete

  • Connection to remote database failed

    I have configured the cman.ora file and changed the connection
    string for the java applet, but I encountered the error
    "The NT Adapter could not establish the connection" when I tried
    to connect to remote database from JDev2.0(beta).
    Any ideas of what are the possible causes for this?
    At the cman.ora file, the setting are:
    cman = (ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=tcp)(HOST=<web_host_ip>)(PORT=1610))
    (ADDRESS=(PROTOCOL=tcp)(HOST=<db_host_ip>)(PORT=1521))
    cman_profile = (parameter_list=
    (MAXIMUM_RELAYS=1024)
    (LOG_LEVEL=1)
    (TRACING=yes)
    (RELAY_STATISTICS=yes)
    (SHOW_TNS_INFO=yes)
    (USE_ASYNC_CALL=yes)
    (AUTHENTICATION_LEVEL=0)
    At the java applet the connection statement are:
    DriverManager.registerDriver (new
    oracle.jdbc.driver.OracleDriver());
    Connection conn =
    DriverManager.getConnection ("jdbc:oracle:thin:" +
    "@(description=(address_list=" +
    "(address=(protocol=tcp)(host=<web_host_ip>)(port=1610))" +
    "(address=(protocol=tcp)(host=<db_host_ip>)(port=1521)))" +
    "(source_route=yes)" +
    "(connect_data=(sid=<orasid>)))", "<user>", "<id>");
    The error at the dos prompt running from JDev2 are:
    java.sql.SQLException: The NT Adapter could not establish the
    connection
    at oracle.jdbc.dbaccess.DBError.check_error(Compiled
    Code)
    at oracle.jdbc.driver.OracleConnection.<init>(Compiled
    Code)
    at oracle.jdbc.driver.OracleDriver.connect(Compiled Code)
    at java.sql.DriverManager.getConnection(Compiled Code)
    at java.sql.DriverManager.getConnection(Compiled Code)
    at test.Applet1.jbInit(Compiled Code)
    at test.Applet1.init(Compiled Code)
    at sun.applet.AppletPanel.run(Compiled Code)
    at java.lang.Thread.run(Compiled Code)
    Thanks,
    Eye Gee
    null

    I am able to connect to the remote database using SQL*plus but
    does it means it is using CMAN connection?
    How do I test the CMAN connection from SQL*plus? Any example for
    me to follow?
    Thanks,
    Eye Gee
    mark tomlinson (guest) wrote:
    : Have you tried using the CMAN connection from something like
    : SQL*plus to verify that it is configured correctly? Everything
    : looks correct, so it might be hiding an actual NET error
    : underneath.
    null

  • 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

  • How to connect Applet to JDBC driver (urgent !!!)

    Hi,
    I had problems getting the applet connected to a database in the server using JDBC. When I run the applet in appletviewer I got the error msg :
    "Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.lang.RuntimePermission
    accessClassInPackage.sun.jdbc.odbc "
    .....this error refers to the line in my source code:
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Please help , thank you!

    Join this topic:
    http://forum.java.sun.com/thread.jsp?forum=48&thread=178759

  • Connecting to MySQL Database with Servlet

    Hi All,
    I want to connect to MySQL Database from servlet.
    I am using Tomcat websever 3.3.1, where i have to set classpath of mysql jdbc driver.
    I tried by copying mysql jdbc driver in so many directiories of Tomcat server but it is
    giving me error like "no specified driver find"
    So please send me all the solutions and how to set the classpath to connect to
    mysql database.
    Thanks

    U r correct that so many people are giving me solutions but that are not working for me
    I think i not correct in setting the classapath to mysql jdbc driver.
    1)I have unjarred correctly and all the classes are present in that.
    yes driver class is there in that .
    2)Now i am using new version of the mysqljdbc that is 2.0.13
    If now any driver after this send me url i will download it and use it
    3)I am unable to under stand what is yourcontext in
    yourcontext/web-inf/lib?
    This is my directory structure.
    c:tomcat in this i have
    bin
    conf
    doc
    lib
    logs
    modules
    native
    webapps
    work
    in bin there are no subdirectories
    in conf i have
    auto,jserv,jk,users
    in doc i have
    appdev,images
    sample( in appdev)
    etc,lib,src,web(in sample)
    images(in sample\web)
    in lib i have
    apps
    common
    container(c:\tomcat\lib)
    in logs,modules there are no subdirectories
    in native (c:\tomcat\native) i have
    mod_jk
    mod_jserv
    in mod_jk i have
    apache 1.3
    common
    iis
    jni
    netscape
    nt_service
    in webapps i have (c:tomcat\webapps)
    Admin,Examples,root
    in Admin i have (c:\tomcat\webapps\admin)
    contextadmin
    Meta-inf
    Test
    Web-inf
    in web-inf (c:\tomcat\webapps\admin\web-inf)
    Classes,lib,script
    in classes i have (c:\tomcat\webapps\admin\web-inf\classes)
    tadm
    in examples (c:\tomcat\webapps\examples) i have
    Images,Jsp,Meta-inf,Servlets,Web-inf
    in web-inf (c:\tomcat\webapps\examples\web-inf) i have
         Classes,jsp
    in classed (c:\tomcat\webapps\examplesweb-inf\classes) i have
    Cal
    Checkbox
    Colors
    Dates
    Error
    Examples
    Num
    Sessions
    in jsp (c:\tomcat\webapps\examples\web-inf\jsp) i have
    applet          
    I think this is enough to give correct answer for me .
    Thanks

  • 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.

  • 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

Maybe you are looking for

  • Help Required - iMovie 11 V Final Cut Express

    Firstly don't shoot me if this has been posted into the wrong place. I've recently and quite successfully been getting to grips with iMovie. I mainly use it for personal projects importing files from .mov files, DVD's and Screen recording software. I

  • Stock Report on Key date.

    Hi, I want to have a report which gives stock available on key dates. Is there any standard report available in sap. Thanks in advance VRH

  • Swing component to use as time editor

    what is the Swing component that we can use to immitate clock component editor in windows? you know, the list where you can select/edit hours,minutes seconds .... is it a JList can somebody give a small example please thanks

  • Individual messages in Mac Mail (ver 4.6) not opening

    In my Mac Mail (ver 4.6), sometimes individual messages don't open in new window. Any ideas?

  • SQL Developer startup

    Hi, i have monitored that the SQL Developer slows down if you have a lot of connections in your connection tree (i have 100-200 connections in my tree); if i start an clean installation without any connection it starts within 30sek But with my connec