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:
Comments (Atom)
Programmingway@Eklavya Technosys!: Computer Solutions || Class-4 || Computer for Scho...
Programmingway@Eklavya Technosys!: Computer Solutions || Class-4 || Computer for Scho... : 1) Choose correct one :- 1) The step by step pla...
-
COMPUTER TERMINOLOGY 1) TCP/IP - Transmission Control Protocol/ Internet Protocol. 2) HTTP...
-
https://makecode.com/_3VxaMo6c3YPp Code 1) What is Make Code Arcade? Answer: Make Code Arcade is a Block based coding. 2) Writ...
-
Check whether the number is negative or positive after taking a number as input from the user. TextWindow . WriteLine ( "Ente...
-
1) ___ is the response of the receiver after perceiving the message. a) Encoding b) Decoding c) Channel d) Feedback 2) Which of the fo...
-
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...
No comments:
Post a Comment