Access database using Java from HTML webpage

Hi,
I've got to create some online maths tests to be taken by students with their marks being stored in a database.
I've wrote some simple java code which can add/remove and modify entries in a test mySQL database that I made. What I now need to do is be able to add entries to the database from a html page.
The math tests will be java applets with the students having to interact according to questions, press submit and their score will be output. The score will then be entered into the database.
The problem I'm having is that with an Applet their are all sorts of security issues (I'm having problems getting images to load in an Applet) so assume I'll face the same security issues when I try to access a database through an applet.
So, could someone please help get started.
Cheers

MVC - I assume you mean model-view-control and not Marvel vs Capcom :)
If so then does this mean I should completely seperate the user interface (the actual applets that will contain the test), the database (that will store the results) and the link between the two?
is it possible to acheive this using Java, Java Applets, Java Script and the database (in my case mySQL) and could you give me some tips on how best to tackle the problem.
Thanks

Similar Messages

  • Setting System DSN for MS Access Database using Java Code

    How to set the system DSN for Access database using Java Code at runtime....???
    Replies are deeply appreciated...

    I found a 3rd Party MS Access JDBC Driver from a Google search. I downloaded and tried the free trial version. It worked fine but we opted not to purchase the full version and went a different route. If you don't find it, let me know and I'll see if I can track down the name of the product we tested.

  • How to use parsing technique to access a particular value from a webpage

    hi,
    i'm in need of a coding to access a particular value from a webpage only by using its link. one of my friend said the we can do this by parsing technique. but i doesn't have knowledge about it. can any one help me?

    ksnagendran26 wrote:
    hi,
    i'm in need of a coding to access a particular value from a webpage only by using its link. one of my friend said the we can do this by parsing technique. but i doesn't have knowledge about it. can any one help me?I'm sorry could you explain in detail what do you mean by +"access a particular value from a webpage only by using its link"+?

  • How To Store pdf or doc file in Oracle Database using Java Jdbc?

    can any one help me out How To Store pdf or doc file in Oracle Database using Java Jdbc in JSP/Serlet? i tried like anything. using blob also i tried. but i am able 2 store images in DB not files. please if u know or else if u have some code like this plz send that to me, and help me out plz. i need that urgent.

    Hi.. i am not getting error, But i am not getting the original contents from my file. i am getting all ASCII vales, instead of my original data. here i am including my code.
    for Adding PDF in DB i used image.jsp
    Database table structure (table name. pictures )
    Name Null? Type
    ID NOT NULL NUMBER(11)
    IMAGE BLOB
    <%@ page language="java" import="java.util.*,java.sql.*,java.io.*" pageEncoding="ISO-8859-1"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <%
    try{
         Class.forName("oracle.jdbc.driver.OracleDriver");
         Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
         PreparedStatement ps,pstmt,psmnt;
         ps = con.prepareStatement("INSERT INTO pictures VALUES(?,?)");
    File file =
    new File("D:/info.pdf");
    FileInputStream fs = new FileInputStream(file);
    ps.setInt(1,4);
    ps.setBinaryStream(2,fs,fs.available());
    int i = ps.executeUpdate();
    if(i!=0){
    out.println("<h2>PDF inserted successfully");
    else{
    out.println("<h2>Problem in image insertion");
    catch(Exception e){
    out.println("<h2>Failed Due To "+e);
    %>
    O/P: PDF inserted successfully
    i tried to display that pdf using servlet. i am giving the code below.
    import java.io.IOException;
    import java.sql.*;
    import java.io.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class DispPDF extends HttpServlet {
         * The doGet method of the servlet. <br>
         * This method is called when a form has its tag value method equals to get.
         * @param request the request send by the client to the server
         * @param response the response send by the server to the client
         * @throws ServletException if an error occurred
         * @throws IOException if an error occurred
         public void service(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {
              //response.setContentType("text/html"); i commented. coz we cant use response two times.
              //PrintWriter out = response.getWriter();
              try{
                   InputStream sPdf;
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                        Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
                        PreparedStatement ps,pstmt,psmnt;
                   psmnt = con.prepareStatement("SELECT image FROM pictures WHERE id = ?");
                        psmnt.setString(1, "4"); // here integer number '4' is image id from the table.
                   ResultSet rs = psmnt.executeQuery();
                        if(rs.next()) {
                   byte[] bytearray = new byte[1048576];
                        //out.println(bytearray);
                        int size=0;
                        sPdf = rs.getBinaryStream(1);
                        response.reset();
                        response.setContentType("application/pdf");
                        while((size=sPdf.read(bytearray))!= -1 ){
                        //out.println(size);
                        response.getOutputStream().write(bytearray,0,size);
                   catch(Exception e){
                   System.out.println("Failed Due To "+e);
                        //out.println("<h2>Failed Due To "+e);
              //out.close();
    OP
    PDF-1.4 %âãÏÓ 2 0 obj <>stream xœ+är á26S°00SIá2PÐ5´1ôÝ BÒ¸4Ü2‹ŠKüsSŠSŠS4C²€ê P”kø$V㙂GÒU×713CkW )(Ü endstream endobj 4 0 obj <>>>/MediaBox[0 0 595 842]>> endobj 1 0 obj <> endobj 3 0 obj <> endobj 5 0 obj <> endobj 6 0 obj <> endobj xref 0 7 0000000000 65535 f 0000000325 00000 n 0000000015 00000 n 0000000413 00000 n 0000000168 00000 n 0000000464 00000 n 0000000509 00000 n trailer <<01b2fa8b70ac262bfa939cc786f8770c>]/Root 5 0 R/Size 7/Info 6 0 R>> startxref 641 %%EOF
    plz help me out.

  • How do you query Oracle RDF database using Java program?

    Does anyone know how to get data out of the oracle RDF database using Java?
    I'm running the following java code and it returns basically null values. My guess is that the get_triple() function returns a dataset other than resultset. I've tried searching the Oracle web site. Am I supposed to be using CLOB object? Any help would be appreciated. Thanks
    sql = "SELECT a.triple.GET_TRIPLE() AS triple FROM family_rdf_data a";
    ResultSet rs = stmt.executeQuery( sql ) ;
    while ( rs.next() )
    System.out.println( rs.getString(1) ) ;
    rs.close() ;

    get_triple() returns an object, and the code would be different from the code of retrieving a string. Some sample code for retrieving objects is at http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.html
    get_subject(), get_property() return strings so the code below should work. get_object() returns a CLOB so different handling would be required and there is some sample code at the link above.
    Melli

  • How to restore a mysql dump file to database using java

    hai friends,
    i'm developing an application. in that i need to back up and restore the database. i'm using mysql.
    in that i used a code to back up the db.. its working perfectly and the dump file is created perfectly..
    but while trying to restore the dump file nothing is happening...
    can anyone provide me a sample code to restore the dump to database using java code...
    thanks in advance...

    The first, biggest mistake you made in the code is that you didn't read standard output and error from the process, and/or you're ignoring exceptions. Because if you did, you would have read error messages that would have given you a clue what's wrong. (either that, or you ignored the clues, or didn't understand them and failed to tell us what the error messages are)
    The second mistake is that you invoked exec with the call that takes a single string, when that string includes whitespace not used as delimiters.
    The third mistake was that you used a terrible subject line for your post. Your problem is that you're having trouble with Runtime.exec. The fact that it's about mysql isn't relevent.
    The fourth mistake is that you didn't mention Runtime.exec at all until pushed. You should provide these details. When you try to self-diagnose something that you don't understand, and then hide information, you're just wasting everybody's time, including your won.
    The fifth mistake is that you're using poor spelling.
    The sixth mistake is that you still haven't said why you're doing this in Java.

  • Getting error: E_ADEPT_DISTRIBUTOR_AUTH while access ACS4 using java

    Hello Everyone,
    Thanks for ur time. I am new to ACS4.
    I am trying to access ACS4 using java code and view the response for ALL ITEMS.
    Below is the code that i created using UploadTest reference.
            String targetURL_viewAllItems = "http://xxx.xxxxxxx.com:8080/admin/ManageResourceItem";
            String nonce = Base64.encodeBytes(makeNonce());   
            byte[] hmacKeyBytesSHA1 = TestXMLUtils.SHA1(PASSWORD);
            String hmacKey = TestXMLUtils.hmac(hmacKeyBytesSHA1);
            String output_viewAllItems = "<request action='get' auth='builtin' xmlns='http://ns.adobe.com/adept'><nonce>"+nonce+"</nonce><expiration>2011-08-17T09:43:34-00:00</expiration><hmac>"+hmacKe y+"</hmac></request>";
            System.out.println(output_viewAllItems);
            sendContent(output_viewAllItems, createConnection(targetURL_viewAllItems));
    But after executing this code from my desktop, i am getting the below error response:
    <error xmlns="http://ns.adobe.com/adept" data="E_ADEPT_DISTRIBUTOR_AUTH http://xxx.xxxxxxx.com:8080/admin/ManageResourceItem urn:uuid:00000000-0000-0000-0000-000000000001"/>
    Please help me to figure out the error.
    Thanks
    Rupal Chatterjee

    Are you sure you are signing the URL/.acsm file correctly for those particular books?

  • How to create sql database using java frame or appelet?

    hi ! i am working on database project i want to create a database using java frame or applet where it asks user to select the location for database to be created , after user have specified the path then the programs creates the database, again i want that database to be read and write by another frame or applet but as user select the path how do i make the connectivity. i just have basic knowledge on java. please give me idea how can i process further.
    thanks a lot

    While duffymo is correct in regard to most major database products, it's my understanding (warning! wild-ass guess coming) that the Hypersonic DB is more "application-centric" and the dynamic creation of databases is part of its design. It's pure Java database software, and therefore is not appropriate for all database projects, in particular those that require extremely high-performance.
    See http://hsqldb.org/
    I've not used it yet (but soon though), and I can't really advise anyone about it.
    However, I'm wondering if you phrased you question in a way that is confusing us. To most of us in casual conversation, a "database" is both (1) a large organized collection of data and (2) the software that is used to organize and access it. However, the phrase "create a database" usually means creating a (1) database (a collection of data) using an already created (2) database software, such as Oracle, MySQL, DB2, HSQDB, etc., etc. If you'r question is, how do a create some new database software using Java, the answer is that this is a very very big and hard thing to do for the general case and probably not something you want to be doing.

  • Integrate 300 MS Access Databases using ODI

    Hi All,
    I am trying to integrate data between 300 similar MS Access databases using ODI. All the source databases have exactly the same data structures. I have done a POC for 3 databases by creating interfaces and could integrate the data between them successfully.
    Now that the project is approved ; Going forward I need to integrate data from 297 MS Access databases, so I need to run the same set of Interfaces on 297 source MS Access Databases with Target DB being the same.
    This integartion work could be labourious as I need to copy 7 interfaces on 297 databases - IS THERE ANY EASY SOLUTION FOR THIS PROBLEM.
    Some one suggested me to use Dynamic Variables in the TOPOLOGY to access all the MS Access databases - BUT NOT SURE IF THAT WORKS.
    APPRECIATE your suggestions.
    Thanks & Regards
    Kay

    The issue you face here is that the Access database is connected to through the JDBC-ODBC bridge to the Access ODBC database driver. You will need to have a separate DSN defined for each of the access databases, if you want to address each individually.
    An alternative approach is to have one DSN set up, one entry in ODI's topology, one interface etc, and each file you wish to use, you rename to a given name first. Thus, when ODI tries to access the database, the ODBC driver finds the then current file. Note that ODI keeps the database connection for the duration of a SESSION, so if you wanted to process all 300 files sequentially, then you would need to run separate sessions for each of the file executions.
    I think this will give you the solution you require without resorting to variables.

  • How do I open a pdf stored in a Microsoft Access database using Visual Basic studios 2012

    Currently I am unable to find a valid method of being able to open a pdf stored in a Microsoft Access database using Visual Basic studios 2012. I've tried displaying the entire database on a form, but when I do this all the other columns show up with
    the correct data besides the one containing the pdf's, it just displays <binary data> in each row down the column. I also tried another method with which you use the database as a dataset and can drag and drop the rows and columns into the form, which
    again works for all the other columns besides the one containing the pdf's but this time I'm unable to interact with the column  at all. 
    Not too sure if this is in the correct place, but any answers or help would be appreciated. Cheers.

    Alex,
    This forum is dedicated to Project and Project Server. You might get better response, if you post to a Visual Basic forum. Here are couple I could find. 
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral%2Cvblanguage&filter=alltypes&sort=lastpostdesc
    Cheers,
    Prasanna Adavi, Project MVP
    Blog:
      Podcast:
       Twitter:   
    LinkedIn:
      

  • How to store file content in BLOB field MySql database using java

    Hi!
    i want to store the file content in a BLOB field in MySql database using java.
    Please help me out..........
    thanx in advance...
    bye

    i stored images in db, and retrieved them. like that cant i store pdf file in db, and retrieve it back using oracle db?
    Plz help me out how to put a file in db. i need complete code. thanks in advance.

  • How to store images in database using java

    hii
    how to store images in database using java..........
    Message was edited by:
    naveennaga

    I asked a similar question once and the answer I got was - Don't.
    Instead, store the images on a drive somewhere and store the path in the database.
    But I'm no expert - that's just what I was told by someone who does this kind of stuff a lot.
    Hope that helps.

  • Can I create Oracle Database using Java ???

    HI ...
    Can I create a Database using Java... ? If yes can any one tell me how ? I mean provide some codeing help... ???

    If you mean a table yes, since the create table statement is exactly that, an SQL statement, if you mean an SID then I would have to say (AFAIK) no.

  • Need to access R3 using IConnectorServiceGateway from portal service.

    Hi everyone,
    I need to access R3 using IConnectorServiceGateway from portal service but unable to access so as I don't get the IPortalComponentRequest. Can anyone help me out on how should i do the connection ?
    Please let me know as soon as possible.
    Thanks
    Ritu

    Hello.
    I think this should work
        * Méthode renvoyant une connexion au backend SAP/R3 via un pool de
        * connexion.
        * @param userLocale  - la locale de l'utilisateur
        * @param user        - utilisateur pour lequel il faut une connection
        * @param systemAlias - système pour se connecter
        * @return une connexion au backend SAP/R3.
        * @throws ConnectionPoolException
        *             levée en cas d'erreur.
       public IConnection getConnection(
             Locale userLocale,
             IUserContext user,
             String systemAlias) throws ConnectionPoolException {
          ConnectionProperties prop = null;
          IConnection connection = null;
          IConnectorGatewayService cgService = null;
          try {
             // Connector Gateway Service.
             cgService = (IConnectorGatewayService) PortalRuntime
                   .getRuntimeResources().getService(IConnectorService.KEY);
             if (cgService == null) {
                throw new ConnectionPoolException(
                      "Error in get Connector Gateway Service...");
             IPortalComponentRequest aRequest;
             if (systemAlias == null) {
                throw new ConnectionPoolException(
                      "System alias 'systemAlias' name is null...");
             // Demande la connexion au service :
             prop = new ConnectionProperties(userLocale, user);
             connection = cgService.getConnection(systemAlias, prop);
          } catch (Exception ex) {
             throw new ConnectionPoolException(ex);
    regards
    Guillaume PATRY

  • Is It Possible to store an entire  file in database using java?

    Hi All,
    I am new to Programming. please help he out Is It Possible to store an entire file in database using java? is possible, can u tell me the way to make this success? Thank you in advance.

    Thanks PhHein
    i got that application. i stored one file in db, and i displayed that in browser. thank u very much.

Maybe you are looking for

  • Final cut pro HD 2 not working with new updates

    recently purchased a new imac. Most of my old programs were not supported. I updated to 10.9 from 10.5. Now, all the programs are running except Final Cut pro HD 2. I get a message sayin"power pc applications are no longer supported" Any suggestions?

  • Flash 11.5  Windows 7 32bit IE9 Crash

    Good Morning, I have a pc that flash seems to cvrash the browser when veiwing any flash movie,  however the funny thing is that when you install it for the first time after installing it works fine, also when the flash player has crashed you are unab

  • How to sync the calendar with gmail-calendar

    I have an E-72 and use the calendar a lot. But how can I sync it with gmail-calendar? Anyone? Thanks! Solved! Go to Solution.

  • (oracle 10.2) Access to v$session from pl/sql code

    Hello, I wonder if anybody can help me with the following problem as I have read some previous posts on similar topics but could not come to a solution so far. The problem is simple: I need to select some columns form v$session from within a PL/SQL b

  • Digital camera video = memory card

    What is the best kind of memory card for videos ( making a video on a digital camera) & how many GBs should i consider on getting?