-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.txt
More file actions
97 lines (88 loc) · 2.23 KB
/
database.txt
File metadata and controls
97 lines (88 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package applets;
import java.sql.*;
public class database1 {
public static void main(String args[]) {
Connection conn=null;
try
{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/person","root","");
//String query="select * from student";
//String query1="update student set name='yoyo' where name='Antariksh'";
Statement stmt=conn.createStatement();
//String query2="update student set name=? where usn=?";
String query3="insert into student(name,usn) values(?,?)";
PreparedStatement ps=null;
/* create procedure getStudName(STUD_ID IN VARCHAR, STUDENT_NAME OUT VARCHAR) AS
BEGIN
SELECT name INTO STUDENT_NAME
FROM Student
WHere ID=STUD_ID;
END;
String query4="{CALL getSTudName(?,?)}";
CallableStatement cs=null;
cs=conn.prepareCall(query4);
cs.setString(1,"1mssj");
cs.registerOutParameter(2,Types.VARCHAR);
cs.execute();
String name=cs.getString(2);
con.setAutoCommit(false);
con.commit();
conn.rollback(); in exception
con.setAutoCommit(false);
Savepoint sp1=con.setSavepoint();
con.rollback(sp1);
con.releaseSavepoint(sp1);
con.commit();
stmt.addBatch(qry1);
stmt.addBatch(qry2);
stmt.executeBatch();
stmt.clearBatch();
con.commit();0
*/
// Statement stmt2=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
// rs.updateString("A","B");
//rs.updateString(1,"A");
//rs.updateRow();
//if(rs.getString("name").equals("PQR"))
//rs.deleteRow();
ps=conn.prepareStatement(query3);
ps.setString(1, "yo5");
ps.setString(2, "1MS15CS022");
ps.execute();
//int row=stmt.executeUpdate(query1);
//System.out.println(row);
//ResultSet rs=stmt.executeQuery(query);
String f1,f2;
//while(rs.next())
//{
// f1=rs.getString("name"); //rs.getString(1);
// f2=rs.getString(2);
// System.out.println(f1+" "+f2);
//}
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if(conn!=null)
conn.close();
}
catch(Exception e)
{
}
}
}
}