1 package jdbcapplication; 2 import java.sql.*; 3 public class InsertDemo 4 { 5 Connection cnt; 6 PreparedStatement pstm; 7 String driver,url; 8 String qry="insert into emp(eid,ename,esal,ejob) values(?,?,?,?)"; 9 InsertDemo() 10 { 11 driver="com.mysql.jdbc.Driver"; 12 url="jdbc:mysql://localhost/bhupesh"; 13 try 14 { 15 cnt=DriverManager.getConnection (url,"root","ashok"); 16 pstm=cnt.prepareStatement(qry); 17 pstm.setInt(1,104); 18 pstm.setString(2,"Ros"); 19 pstm.setInt(3,10300); 20 pstm.setString(4,"Trainer"); 21 pstm.execute(); 22 System.out.println("Sucessfull"); 23 cnt.close(); 24 } 25 catch (SQLException ex) { 26 System.out.println("Error : "+ex.getMessage()); 27 } 28 } 29 public static void main(String args[]) 30 { InsertDemo demo=new InsertDemo(); 31 } 32 } |
Computer Science :: 11th/12th, Computer Engineering :: Degree/Diploma, Coding Concept ( C, C++ & JAVA Programming, JDBC Concept, DBMS - SQL Concept, Data Structure, Communication & Network Concept.
PREPARED INSERT STATEMENTS
Subscribe to:
Posts (Atom)
JAC Board Computer || IIT 2025 || Introductory Information Technology || Class 10 || Practical Examination 2025
Marks Division HOE 30 Marks IT Application Report File 20 Marks Viva - Voce 10 Marks 1) Write an HTML code to generate a web p...
-
1) TCP/IP - Transmission Control Protocol/ Internet Protocol. 2) HTTPs - Hyper Text Transfer Protocol. 3) ICT - Information Comunication Te...
-
1) What is Make Code Arcade? Answer: Make Code Arcade is a coding platform that enables to create block – based program. 2) How ...
-
Programmingway@Eklavya Technosys!: New Year's 2025 | Happiness & Healthier's Life Sty... : भारत कई धर्मों का संगम है, हिंदू, मुस...
No comments:
Post a Comment