Click here to Skip to main content
13,293,894 members (60,192 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 8 Feb 2012

Message Manager

, 8 Feb 2012
Rate this:
Please Sign up or sign in to vote.
Sending and receiving message, user authentication, user permission, priority message


As you know, the amount of source code for Java (Netbeans) on the Internet is much less than other languages??. So I sent this article. This article may be helpful for people who work with Netbeans, Java(J2SE), Mysql. In this article, you will learn: Sending and receiving message, user authentication, user permission, priority message.

Training Tips Article

  1. Working with the Mysql commands from Java (Netbeans)
  2. Message box in Java (Netbeans)
  3. Working with the Java Jtable
  4. How to connect to database from Netbeans (connection string, Mysql authentication)
  5. Working with the Java Jpanel
  6. How ResultSet(RS) works
  7. User management
  8. Giving access to users (user permission)
  9. Priority for letters

In the first, manager with username: admin and password: 313 is entered and the user defines and gives to each user the appropriate permissions.

Using the Code

The database connection and functions are in The following functions and variables are used in this class.

Connection String: A connection string contains initialization information that is passed as a parameter from a data provider to a data source. The syntax depends on the data provider, and the connection string is parsed during the attempt to open a connection. Here we call that connectionUrl.

//connection string //"Archive" is database name

private static String connectionUrl = 
    "jdbc:mysql://localhost:3306/archive user=root & password=123"; 

Retrieve Data function: The function to retrieve records from database and fill those in result set, this function has an input.

public static void retrieveData(String SQL) throws Exception {
    rs = stmt.executeQuery(SQL);
    while ( {
        System.out.println(rs.getString("ProductName") + " : " + 
    rs.getString("QuantityPerUnit") + " : " +
        rs.getString("UnitPrice") + " : " + 
    rs.getString("UnitsInStock") + " : " +
        rs.getString("UnitsOnOrder") + " : " + 
    rs.getString("ReOrderLevel") + " : " + rs.getString("Discontinued"));

Command function: The function for send commands to the database (insert, update, delete).

public static void Command(String SQL) throws Exception {
    try  {
        con=  DriverManager.getConnection(connectionUrl);
        stmt = con.createStatement();
            System.out.print("?? ?????? ????? ??.");
        }catch(Exception insError){
            System.out.print(insError);            }

Select function: This function is used for selecting record(s) with any condition from database and filling those in result set.

public ResultSet select(String SQL)  {
    try  {
    con=  DriverManager.getConnection(connectionUrl);
    stmt = con.createStatement();
     ResultSet s=stmt.executeQuery(SQL);
        return s;
    }catch(Exception insError){
    return null;

Points of Interest

Netbeans is not just for mobile programming. We can develop in this IDE web, Java desktop, Enterprise, PHP, C/C++, etc. application.


  • 7th February, 2012: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

ebrahim amini sharifi
Software Developer (Senior) aisoft-rayvarz
Iran (Islamic Republic of) Iran (Islamic Republic of)
I'm a senior java/j2ee developer. I'm just start be a part-time freelancer. I have years of experience in web application development. I'm good at JSF,Servlet,Applet and also j2ee technologies like JSP/Servlet, Hibernate.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171207.1 | Last Updated 8 Feb 2012
Article Copyright 2012 by ebrahim amini sharifi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid