-
Notifications
You must be signed in to change notification settings - Fork 0
/
mulesoft.java
76 lines (60 loc) · 2.34 KB
/
mulesoft.java
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
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
public class mulesoft
{
private Connection connect()
{
String url = "jdbc:sqlite:C://sqlite/db/test.db";
Connection conn = null;
try {
conn = DriverManager.getConnection(url);
} catch (SQLException e)
{
System.out.println(e.getMessage());
}
return conn;
}
public void insert(String movie_name, String actor, String actress,String director,String year_of_release)
{
String sql = "INSERT INTO details(movie_name,actor,actress,director,year_of_release) VALUES(?,?,?,?,?)";
try (Connection conn = this.connect();
PreparedStatement pstmt = conn.prepareStatement(sql))
{
pstmt.setString(1, movie_name);
pstmt.setString(2, actor);
pstmt.setString(3, actress);
pstmt.setString(4,director);
pstmt.setString(5, year_of_release);
pstmt.executeUpdate();
}
public void selectAll()
{
String sql1 = "SELECT movie_name,actor,actress,director,year_of_release FROM details";
try (Connection conn = this.connect();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql1))
{
while (rs.next())
{
System.out.println(rs.getString("movie_name") + "\t" + rs.getString("actor") + "\t" + rs.getString("actress")+ "\t" + rs.getString("director") + "\t" + rs.getString("year_of_release") );
}
catch (SQLException e)
{
System.out.println(e.getMessage());
}
}
public static void main(String[] args)
{
mulesoft app = new mulesoft();
app.insert("jilla","vijay","thamanna","jose","2000");
app.insert("ayan","surya","thrisha","laljose","2001" );
app.insert("kathi","ajith","deepthi","krishna","2002");
app.insert("vivegam","sharukh","diya","jayan","2003");
app.insert("sura","mohanlal","diana","sudu","2004");
app.insert("pokkiri","mammootty","deepika","ram","2005");
}
}