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)
-
1) Workbook - A workbook is like a book and consists worksheets. 2) Worksheet - A worksheet is working area consists rows and columns. By...
-
Programmingway: SSC ICT PAPER PATTERN : INFORMATION COMMUNICATION TECHNOLOGY (41) (E) (NEW COURSE) NOTE: - (i) All questions are compu...
-
Choose Eklavya, for Computer Education वाह रे जिंदगी, एक साल में बहुत कुछ दिखाया है तूने..!!
No comments:
Post a Comment