diff options
Diffstat (limited to 'Dozentenmodulserver/src/sql/SQL.java')
| -rw-r--r-- | Dozentenmodulserver/src/sql/SQL.java | 93 |
1 files changed, 49 insertions, 44 deletions
diff --git a/Dozentenmodulserver/src/sql/SQL.java b/Dozentenmodulserver/src/sql/SQL.java index 9a8c92fc..ed1acbec 100644 --- a/Dozentenmodulserver/src/sql/SQL.java +++ b/Dozentenmodulserver/src/sql/SQL.java @@ -6,6 +6,7 @@ import java.sql.ResultSet; import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
@@ -13,6 +14,7 @@ import java.util.Random; import org.apache.log4j.Logger;
import server.BinaryListener;
+import server.ServerHandler;
public class SQL {
@@ -446,7 +448,7 @@ public class SQL { }
return -1;
}
-
+ /**
@@ -456,12 +458,10 @@ public class SQL { * @return
*/
- public boolean deleteImage(String id, String version) {
+ public boolean deleteImage(Connection con, String id, String version) {
try {
-
- Connection con=DriverManager.getConnection
- ("jdbc:mysql://127.0.0.1/bwLehrpool?user=root&password=slx-ng-open");
+
Statement stm=con.createStatement();
System.out.println("delete image");
@@ -470,16 +470,17 @@ public class SQL { "AND imageVersion = '"+version+"';");
return true;
+
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- return false;
}
+ return false;
}
- - public int updateLectureData(Connection con, int pk_person, int pk_image,
- int imageversion, String name, String desc, String shortdesc,
+ + public int updateLectureData(Connection con, int pk_image,
+ int imageversion, String name, String newName ,String desc, String shortdesc, String start, String end, boolean isactive, String id) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
@@ -490,36 +491,24 @@ public class SQL { }
try {
Statement stm = con.createStatement();
- Random random = new Random();
- int uid = random.nextInt();
- stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_VLData_lecture`(`lectureID`,`name`,`isActive`,`startTime`,`endTime`,`lastUsed`,`shortDescription`,`description`,`imageID`,`imageVersion`,`admin_createTime`,`admin_changeTime`,`admin_owner`,`admin_change_by`)VALUES('"
- + uid
- + "','"
- + name
- + "','"
- + active_bol
- + "','"
- + start
- + "','"
- + end
- + "','"
- + formatter.format(new Date())
- + "','"
- + shortdesc
- + "','"
- + desc
- + "','"
- + pk_image
- + "','"
- + imageversion
- + "','"
- + formatter.format(new Date())
- + "','"
- + formatter.format(new Date())
- + "','"
- + pk_person
- + "','"
- + pk_person + "');");
+ stm.executeUpdate("UPDATE `bwLehrpool`.`m_VLData_lecture` SET `name` = '"
+ +newName
+ +"',`isActive` = '"
+ +active_bol
+ +"',`startTime` = '"
+ +start
+ +"',`endTime` = '"
+ +end
+ +"',`description` = '"
+ +desc
+ +"',`imageID` = '"
+ +pk_image
+ +"',`imageVersion` = '"
+ +imageversion
+ +"',`admin_changeTime` = '"
+ +formatter.format(new Date())
+ +"'WHERE `lectureID` = '"
+ +id+"';" );
con.commit();
@@ -528,12 +517,28 @@ public class SQL { e.printStackTrace();
}
-
- //return false;
- //}
- return 0;
}
- +
+ public boolean connectedToEvents (Connection con, String id, String version) {
+
+ try {
+
+ Statement stm=con.createStatement();
+
+ stm.executeUpdate("SELECT ...VERANSTALTUNG_VERKNÜPFUNG... FROM " +
+ "bwLehrpool.m_VLData_imageInfo where GUID_imageID = '"+id+"' " +
+ "AND imageVersion = '"+version+"';");
+
+ return true;
+
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return false;
+
+ } }
|
