-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPost.java
More file actions
32 lines (25 loc) · 793 Bytes
/
Post.java
File metadata and controls
32 lines (25 loc) · 793 Bytes
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
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
public class Post {
String text;
Account a;
boolean foundsth;
ArrayList<comment> c;
Post(){
}
Post(String text,Account a,boolean foundsth) throws SQLException{
this.text = text;
this.a = a;
this.foundsth = foundsth;
Connection myconn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Masroka","root","Fucklove7263218000");
PreparedStatement myStmt = myconn.prepareStatement("insert into Post(text,foundsth,UserName) values(?,?,?)");
myStmt.setString(1, text);
myStmt.setBoolean(2, foundsth);
myStmt.setString(3, a.Username);
myStmt.executeUpdate();
myconn.close();
}
}