what are java and Database?

what is java?


Java is a high-level programming language that is used to create a complete application that is run on a single system or distributed among servers and clients in a network. it is used to create small or big application modules or applets.

Java Database


As you know java is a high-level programming language that is used to create an application and a powerful application needs some space to store some data. for this, we are using the database to store the data. data is store in many forms like numbers, strings, audio, video, image, etc.

And in this, I am showing you how to store the data in the database using MySQL and PHP. I am using NetBeans IDE to create an application. and MySQL to give commands to the database and in PHP localhost I am storing the data. To store the data is a very easy task you just have to follow the sequence and write the appropriate code. Follow my Articles to learn How to store the data in a database using java NetBeans.

I am using java Swing to develop applications. I am showing you everything clearly so just follow the steps.
First of all, you have to install java and NetBeans and create a new Project give the name of the project and hit enter.

Now it is your choice what to do now Insert the data, delete the data, Update the data and so on.
So before everything first you have to create the A GUI (Graphical User Interface is a system of interactive visual components for computer software. A GUI displays objects that convey information, and represent actions that can be taken by the user.)

Now, First of all I am showing you how to insert the data. for this you have to follow the video.

Now, If you watch this video then you know well how to insert the data into the database. but still, I provide the source code file below you can copy and paste this code in your IDE to make your work easy.

But first of all, you have to write:

Connection conn;
PreparedStatement st;

Now, copy the code below and paste this code inside the button. to write the code in the button section just double click on the button and that’s it.

try {

    String user = uname.getText();
    String mail = email.getText();
    String mob = mobile.getText();

    Class.forName("com.mysql.jdbc.Driver");
    conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/demo","root","");
    st = conn.prepareStatement("insert into users(username,email,mobile)values(?,?,?)");
    st.setString(1,user);
    st.setString(2,mail);
    st.setString(3,mob);
    st.executeUpdate();
    JOptionPane.showMessageDialog(this, "Data inserted Successfully");

    uname.setText("");
    email.setText("");
    mobile.setText("");
    uname.requestFocus();


} catch (ClassNotFoundException ex) {
    Logger.getLogger(insertdata.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
    Logger.getLogger(insertdata.class.getName()).log(Level.SEVERE, null, ex);
}

I hope you understand the code and if now then you can contact me comment down below or DM on what’s app.
THANK YOU

1 thought on “what are java and Database?”

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart