Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2004
    Messaggi
    196

    Errore connessione db

    Salve ho scritto il seguente codice

    "
    <html>
    <%@ page language="java" import="javazoom.upload.*,java.util.*" %>
    <%@ page errorPage="ExceptionHandler.jsp" %>

    <jsp:useBean id="upBean" scope="application" class="javazoom.upload.UploadBean" >
    <%
    Properties props = new Properties();
    // Modify info below to fit to your database settings.
    props.put("user","postgres");
    props.put("password","postgres");
    upBean.setDatabasestore("sun.jdbc.odbc.JdbcOdbcDri ver",
    "jdbcostgresql://localhost:5432/cms", props);
    // If you have get a JDBC Connection from a javax.sql.DataSource
    // Then use upBean.setDatabasestore(YourConnection);
    // Also, uncomment and modify variables below if you need to map to your own database schema.
    //UploadBean.SQLUPLOADTABLE = "UPLOADS";
    //UploadBean.SQLUPLOADID = "UPLOADID";
    //UploadBean.SQLUPLOADFILENAME = "FILENAME";
    //UploadBean.SQLUPLOADFILE = "BINARYFILE";
    // Note that if you need to modify SQL request then see UploadBean
    // add-ons section to plug a custom DBStore implementation (BLOB, ...).
    %>
    </jsp:useBean>
    <jsp:setProperty name="upBean" property="overwrite" value="true" />

    <head>
    <title>Samples : Database Upload</title>
    <style TYPE="text/css">
    <!--
    .style1 {
    font-size: 12px;
    font-family: Verdana;
    }
    -->
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <ul class="style1">
    <%
    if (MultipartFormDataRequest.isMultipartFormData(requ est))
    {
    // Uses MultipartFormDataRequest to parse the HTTP request.
    MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
    String todo = null;
    if (mrequest != null) todo = mrequest.getParameter("todo");
    if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
    {
    Hashtable files = mrequest.getFiles();
    if ( (files != null) && (!files.isEmpty()) )
    {
    UploadFile file = (UploadFile) files.get("uploadfile");
    if (file != null) out.println("[*]Form field : uploadfile"+"
    Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+"
    Content Type : "+file.getContentType());
    // Store uploaded files in database now. Third parameter allows to pass options Map.
    HashMap options = null;
    // Sample advanced options.
    //options = new HashMap();
    //options.put("dbstore.uploadid","id."+System.curren tTimeMillis());
    //options.put("dbstore.filesize","enabled");
    //options.put("dbstore.filetype","enabled");
    //options.put("dbstore.customcolumn.created_date",ne w Date());
    upBean.store(mrequest, "uploadfile", options);
    // int lastid = ((DefaultDBStore)upBean.getDatabasestoreimplementa tion()).getLastId();
    }
    else
    {
    out.println("[*]No uploaded files");
    }
    }
    else out.println("
    todo="+todo);
    }
    Vector history = upBean.getHistory();
    int amount = 0;
    if (history != null) amount = history.size();
    %>

    (Uploaded files : <%= amount %>)[/list]
    <form method="post" action="DatabaseUpload.jsp" name="upform" enctype="multipart/form-data">
    <table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
    <tr>
    <td align="left">Select
    a file to upload :
    </td>
    </tr>
    <tr>
    <td align="left">
    <input type="file" name="uploadfile" size="50">
    </td>
    </tr>
    <tr>
    <td align="left">
    <input type="hidden" name="todo" value="upload">
    <input type="submit" name="Submit" value="Upload">
    <input type="reset" name="Reset" value="Cancel">
    </td>
    </tr>
    </table>


    "
    dove vorrei fare l'upload di un file su un db postgres,ma mida il seguente errore java.lang.NullPointerException; chi mi aiuta a capire dove sbaglio??? grazie assai

  2. #2
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,463

    Moderazione

    Ho modificato il titolo aggiungendo il linguaggio di programmazione.

    Ricordati di indicarlo in futuro, come da Regolamento.

    Ciao!
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.