1 package
jdbcapplication;
2 import java.sql.*;
3 public class Selectstmt
4 {
5 Connection cnn;
6 Statement stmt;
7 String driver,url;
8 ResultSet rs;
9 String qry="select * from emp";
10 Selectstmt()
11 {
12 driver="com.mysql.jdbc.Driver";
13 url="jdbc:mysql://localhost/bhupesh";
14 try
15 {
16 cnn=DriverManager.getConnection(url,"root","ashok");
17 stmt=cnn.createStatement();
18 rs=stmt.executeQuery(qry);
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 cnn.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 Selectstmt demo=new
Selectstmt();
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.
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