Friday, March 24, 2017
How to Send SMS using PHP? [With Source Code]
Monday, March 6, 2017
How to Create a Mail Transfer System in PHP ?
Download Sendmail from here: http://www.sendmail.com/sm/open_source/download/8.15.2/
you have to download Code from because php code cannot include in the directly here because the blogger execute that code.
https://www.techsupportnep.com/programming/php/how-to-send-email-using-php.html
you have to download Code from because php code cannot include in the directly here because the blogger execute that code.
https://www.techsupportnep.com/programming/php/how-to-send-email-using-php.html
Friday, March 3, 2017
How To Insert Update Delete And Display Data In jTable
code:
package idusnewjava;
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
public class NewJFrame extends javax.swing.JFrame {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
public NewJFrame() {
initComponents();
showTableData();
}
//insert
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try{
String sql = "INSERT INTO idusjavanew"
+"(fname, lname, address)"
+"VALUES (?,?,?)";
con = DriverManager.getConnection("jdbc:mysql://localhost/idusjavanew","root","");
pst = con.prepareStatement(sql);
pst.setString(1,fname.getText());
pst.setString(2,lname.getText());
pst.setString(3,add.getText());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "inserted successfully");
}
catch(SQLException | HeadlessException ex){
JOptionPane.showMessageDialog(null, ex);
}
showTableData();
}
//delete
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try{
String sql = "DELETE FROM idusjavanew WHERE Rollno =?";
con = DriverManager.getConnection("jdbc:mysql://localhost/idusjavanew","root","");
pst = con.prepareStatement(sql);
pst.setString(1,Rollno.getText());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "delete successfully");
}
catch(SQLException | HeadlessException ex){
JOptionPane.showMessageDialog(null, ex);
}
showTableData();
}
//update
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
try{
String sql = "UPDATE idusjavanew SET fname=?,lname=?,address=? WHERE Rollno=?";
con = DriverManager.getConnection("jdbc:mysql://localhost/idusjavanew","root","");
pst = con.prepareStatement(sql);
pst.setString(4, Rollno.getText());
pst.setString(1,fname.getText());
pst.setString(2,lname.getText());
pst.setString(3,add.getText());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "updated successfully");
}
catch(SQLException | HeadlessException ex){
JOptionPane.showMessageDialog(null, ex);
}
showTableData();
}
//connect database with jtable
Before writing the below code make sure that you have download the rs2xml.jar file and add that file in libraries folder of your project. For more watch the following video.
public void showTableData(){
try{
con = DriverManager.getConnection("jdbc:mysql://localhost/idusjavanew","root","");
String sql = "SELECT * FROM idusjavanew";
pst = con.prepareStatement(sql);
rs=pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
}
package idusnewjava;
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import net.proteanit.sql.DbUtils;
public class NewJFrame extends javax.swing.JFrame {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
public NewJFrame() {
initComponents();
showTableData();
}
//insert
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try{
String sql = "INSERT INTO idusjavanew"
+"(fname, lname, address)"
+"VALUES (?,?,?)";
con = DriverManager.getConnection("jdbc:mysql://localhost/idusjavanew","root","");
pst = con.prepareStatement(sql);
pst.setString(1,fname.getText());
pst.setString(2,lname.getText());
pst.setString(3,add.getText());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "inserted successfully");
}
catch(SQLException | HeadlessException ex){
JOptionPane.showMessageDialog(null, ex);
}
showTableData();
}
//delete
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
try{
String sql = "DELETE FROM idusjavanew WHERE Rollno =?";
con = DriverManager.getConnection("jdbc:mysql://localhost/idusjavanew","root","");
pst = con.prepareStatement(sql);
pst.setString(1,Rollno.getText());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "delete successfully");
}
catch(SQLException | HeadlessException ex){
JOptionPane.showMessageDialog(null, ex);
}
showTableData();
}
//update
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
try{
String sql = "UPDATE idusjavanew SET fname=?,lname=?,address=? WHERE Rollno=?";
con = DriverManager.getConnection("jdbc:mysql://localhost/idusjavanew","root","");
pst = con.prepareStatement(sql);
pst.setString(4, Rollno.getText());
pst.setString(1,fname.getText());
pst.setString(2,lname.getText());
pst.setString(3,add.getText());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "updated successfully");
}
catch(SQLException | HeadlessException ex){
JOptionPane.showMessageDialog(null, ex);
}
showTableData();
}
//connect database with jtable
Before writing the below code make sure that you have download the rs2xml.jar file and add that file in libraries folder of your project. For more watch the following video.
public void showTableData(){
try{
con = DriverManager.getConnection("jdbc:mysql://localhost/idusjavanew","root","");
String sql = "SELECT * FROM idusjavanew";
pst = con.prepareStatement(sql);
rs=pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
}
Subscribe to:
Comments (Atom)