Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:57:09+00:00 2026-06-14T12:57:09+00:00

How to retrieve data from a form and to send it to a MySQL

  • 0

How to retrieve data from a form and to send it to a MySQL database via JDBC?

Here’s my procedure:

main class:

public class Dati extends MVCPortlet {

    public static Connection con() {
        Connection conn = null;
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
        } catch (Exception ex) {
            System.out.println("Errore");
        }

        // APRI CONNESSIONE

        try {
            conn = DriverManager.getConnection("jdbc:mysql://localhost/db_alex","root","25071984");
            System.out.println("Connessione effettuata");
            return conn;
        } catch (SQLException ex) {
            System.out.println("SQlException: " + ex.getMessage());
            System.out.println("SQLState: " + ex.getSQLState());
            System.out.println("VendorError: " + ex.getErrorCode());
            return null;
        }
    }

    public void Invio (ActionRequest actionRequest, ActionResponse actionResponse) 
    throws PortletException, IOException {
        String username = actionRequest.getParameter("username");
        String password = actionRequest.getParameter("password");

        Connection conn = null;

        try {

        Statement st = conn.createStatement();
        st.executeUpdate("INSERT INTO contacts (username,password) values ('"+username+"','"+password+"')");
        System.out.println("Inserimento avvenuto con successo");
        } catch (Exception e) {
            System.out.println("Inserimento non avvenuto");
        }
    }
}

view.jsp

<%
/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<portlet:actionURL name="Invio" var="Invio"/>

<form method="post" action="actionURL/>">

    <input type="text" name="username">
    <input type="password" name="password">
    <input type="submit" value="Invia!">    

</form> 

I don’t know where my fault is. I was reading Portlet is temporarily unavailable and applying that rule, but Liferay says I’m wrong.

Which is the correct procedure to store?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:57:11+00:00Added an answer on June 14, 2026 at 12:57 pm

    you define actionURL Invio as a java object in view.jsp but you reference it wrong.
    you should reference it in <%= %> tag. actually your form tag should look like this:

    <form method="post" action='<%=Invio%>'>
    
    <input type="text" name="username">
    <input type="password" name="password">
    <input type="submit" value="Invia!">    
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Iam trying to retrieve data from mysql database into stylesheet.php but it is not
I am trying to retrieve data from mysql database using PDO but DATABASE NOT
I am trying to figure out how to retrieve data from a MySQL database
trying to retrieve some data from the database and put in into my form.
How to retrieve data from sqlite database? Getting return value zero. -(id)init{ if(self==[super init]){
I'm attempting to retrieve data from a SolarWinds network performance database (MS SQL 2005)
I am trying to send form data from one page to another using C#
I have a program in which I have to retrieve data from database. I
I am trying to retrieve data from SQL Server into my form. I am
Is it possible to retrieve data from multiple tables in a LINQ-to-sql database to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.