Posts

Showing posts with the label Program

How data is insert into Database (Mysql) by console application

Image
Source Code   import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.util.Scanner; import java.sql.ResultSet; public class Database{ public static void main (String [] args) throws SQLException { // object to ge input from user Scanner ip = new Scanner (System.in); // read values from user System.out.println("Please enter the ID"); int Id=ip.nextInt(); System.out.println("Please enter the Name"); String name= ip.next(); // url (path and port) of database in the computer String url="jdbc:mysql://localhost:3306/hu"; // establish the connection with the database by giving user name "root"and passphrase (password) "1122" Connection con= DriverManager.getConnection(url,"root","1122"); // create a statement Statement st= con.createStatement(); // insert a query t...

How data retrieve from Database (Mysql)

Image
import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; import java.sql.ResultSet; public class Database{ public static void main (String [] args) throws SQLException { // url (path and port) of database in the computer String url="jdbc:mysql://localhost:3306/world"; // establish the connection with the database by giving user name "root"and passphrase (password) "1122" Connection con= DriverManager.getConnection(url,"root","1122"); //to give the query to the database we must create a statement Statement st = con.createStatement(); //to get the retrieved the form table we create a result set all the data is store the in the result set variable ResultSet rs= st.executeQuery("Select * from country where code= \'Pak\'"); // loop is used to get the value from result set while(rs.next()) { String a...

Smart Portal | Complete Software for University

Image
Screenshots Source Code Class No.1 import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JFrame; import javax.swing.JButton; import java.awt.BorderLayout; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.ImageIcon; import java.awt.Toolkit; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.SystemColor; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Welcome extends JFrame { // The main executional part of the whole the software public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Welcome frame = new Welcome(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } //construc...