From cbc155422ac3181ee04e75653e6f302594a2e006 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Apr 2014 10:41:11 +0200 Subject: Verbindung korrigiert --- Dozentenmodulserver/src/sql/SQL.java | 185 ++++++++++++++++------------------- 1 file changed, 85 insertions(+), 100 deletions(-) (limited to 'Dozentenmodulserver/src/sql/SQL.java') diff --git a/Dozentenmodulserver/src/sql/SQL.java b/Dozentenmodulserver/src/sql/SQL.java index daffbf0b..5ae5fde0 100644 --- a/Dozentenmodulserver/src/sql/SQL.java +++ b/Dozentenmodulserver/src/sql/SQL.java @@ -1,10 +1,7 @@ package sql; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; +import java.sql.*; + import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -18,8 +15,8 @@ import server.ServerHandler; public class SQL { - private static Logger log = Logger.getLogger( BinaryListener.class ); - + private static Logger log = Logger.getLogger(BinaryListener.class); + public Connection getConnection() { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); @@ -54,7 +51,8 @@ public class SQL { + pass + "'),'10001','12345','/srv/openslx/nfs/temp');"); con.commit(); - log.info(new Date() + " - created FTPUser "+user+" : "+pass+"."); + log.info(new Date() + " - created FTPUser " + user + " : " + pass + + "."); return ret; } catch (SQLException e) { // TODO Auto-generated catch block @@ -73,11 +71,11 @@ public class SQL { .executeUpdate("DELETE FROM `bwLehrpool`.`FtpUsers` where User like '" + user + "';"); con.commit(); - log.info(new Date() + " - FTPUser "+user+" deleted."); + log.info(new Date() + " - FTPUser " + user + " deleted."); return ret; } catch (SQLException e) { // TODO Auto-generated catch block - log.info(new Date() + " - Could not delete FTPUser "+user+"."); + log.info(new Date() + " - Could not delete FTPUser " + user + "."); e.printStackTrace(); } return -1; @@ -215,44 +213,31 @@ public class SQL { Random random = new Random(); int uid = random.nextInt(); stm.executeUpdate("INSERT INTO `bwLehrpool`.`m_VLData_imageInfo`(`GUID_imageID`,`imageVersion`,`image_name`,`image_path`,`image_lastCall`,`image_create_time`,`image_update_time`,`image_owner`,`image_change_by`,`rec_create_time`,`rec_change_time`,`rec_owner`,`rec_change_by`,`content_operatingSystem`,`status_isCompressed`,`status_isSecure`,`status_isOptimzed`,`status_isValid`,`status_isReady`,`status_isDeleted`,`status_isLastOfficialVersion`,`cond_hasLicenseRestriction`,`cond_hasInternetRestriction`,`cond_minRAM`,`cond_minCPUs`)VALUES('" - + uid //GUID_imageID - + "',1,'" //imageVersion - + imagename //image_name - + "','" - + imagePath //image_path - + "','" - + formatter.format(new Date()) //image_lastCall - + "','" - + formatter.format(new Date()) //image_create_time - + "','" - + formatter.format(new Date()) //image_update_time - + "','" - + pk_person //image_owner - + "','" - + pk_person //image_change_by - + "','" - + formatter.format(new Date()) //rec_create_time - + "','" - + formatter.format(new Date()) //rec_change_time - + "','" - + pk_person //rec_owner - + "','" - + pk_person //rec_change_by - + "',0" //content_operatingSystem - + ",1" //status_isCompressed - + ",1" //status_isSecure - + ",1" //status_isOptimzed - + ",1" //status_isValid - + ",1" //status_isReady - + ",0" //status_isDeleted - + ",0,'" //status_isLastOfficialVersion - + license_bol //cond_hasLicenseRestriction - + "','" - + internet_bol //cond_hasInternetRestriction - + "','" - + ram //cond_minRAM - + "','" - + cpu //cond_minCPUs + + uid // GUID_imageID + + "',1,'" // imageVersion + + imagename // image_name + + "','" + imagePath // image_path + + "','" + formatter.format(new Date()) // image_lastCall + + "','" + formatter.format(new Date()) // image_create_time + + "','" + formatter.format(new Date()) // image_update_time + + "','" + pk_person // image_owner + + "','" + pk_person // image_change_by + + "','" + formatter.format(new Date()) // rec_create_time + + "','" + formatter.format(new Date()) // rec_change_time + + "','" + pk_person // rec_owner + + "','" + pk_person // rec_change_by + + "',0" // content_operatingSystem + + ",1" // status_isCompressed + + ",1" // status_isSecure + + ",1" // status_isOptimzed + + ",1" // status_isValid + + ",1" // status_isReady + + ",0" // status_isDeleted + + ",0,'" // status_isLastOfficialVersion + + license_bol // cond_hasLicenseRestriction + + "','" + internet_bol // cond_hasInternetRestriction + + "','" + ram // cond_minRAM + + "','" + cpu // cond_minCPUs + "');"); con.commit(); @@ -448,8 +433,6 @@ public class SQL { } return -1; } - - /** * @@ -457,33 +440,33 @@ public class SQL { * @param version * @return */ - - public boolean deleteImage(Connection con, String id, String version) { - - System.out.println("delete image"); - + + public boolean deleteImage(Connection con, String id, String version) { + + System.out.println("delete image"); + try { - Statement stm=con.createStatement(); - + Statement stm = con.createStatement(); System.out.println("delete image"); - - stm.executeUpdate("DELETE FROM bwLehrpool.m_VLData_imageInfo where GUID_imageID = '"+id+"' " + - "AND imageVersion = '"+version+"';"); - + + stm.executeUpdate("DELETE 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; - } - + } + 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) { + 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"); int active_bol = 0; @@ -494,54 +477,56 @@ public class SQL { try { Statement stm = con.createStatement(); 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+"';" ); + + 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(); - } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } - + return 0; } - - public boolean connectedToEvents (Connection con, String id, String version) { - + + public boolean connectedToEvents(Connection con, String id, String version) { + try { - Statement stm=con.createStatement(); - - ResultSet rs = stm.executeQuery("SELECT ...VERANSTALTUNG_VERKNÜPFUNG... FROM " + - "bwLehrpool.m_VLData_imageInfo where GUID_imageID = '"+id+"' " + - "AND imageVersion = '"+version+"';"); - + Statement stm = con.createStatement(); + + ResultSet rs = stm + .executeQuery("SELECT ...VERANSTALTUNG_VERKNÜPFUNG... FROM " + + "bwLehrpool.m_VLData_imageInfo where GUID_imageID = '" + + id + + "' " + + "AND imageVersion = '" + + version + + "';"); + return !rs.wasNull(); - - + } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } - + return false; - - } + + } } -- cgit v1.2.3-55-g7522