1 package jdbcapplication; 2 import java.sql.*; 3 public class Selectinfo 4 { 5 Connection cnt; 6 PreparedStatement pstm; 7 String driver,url; 8 ResultSet rs; 9 String qry="select * from emp"; 10 Selectinfo() 11 { 12 driver="com.mysql.jdbc.Driver"; 13 url="jdbc:mysql://localhost/bhupesh"; 14 try 15 { 16 cnt=DriverManager.getConnection (url,"root","ashok"); 17 pstm=cnt.prepareStatement(qry); 18 rs=pstm.executeQuery(); 19 while(rs.next()) 20 { 21 int id=rs.getInt(1); 22 String name=rs.getString(2); 23 int sal=rs.getInt(3); 24 String job=rs.getString(4); 25 26 System.out.println(" | "+id+" | "+name+ " | "+sal+" | "+job); 27 } 28 System.out.println("Sucessfull Records Done"); 29 rs.close(); 30 cnt.close(); 31 32 } 33 catch (SQLException ex) { 34 System.out.println("Error : "+ex.getMessage()); 35 } 36 } 37 public static void main(String args[]) 38 { 39 Selectinfo demo=new Selectinfo(); 40 } 41 } |
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 SELECT 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