Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package diaryclasses;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.Statement;
- import java.util.Date;
- /**
- *
- * @author Satik
- */
- public class DiaryRecord {
- private int id;
- private String caption;
- private String description;
- private Date started;
- private Date finished;
- private int iduser;
- public DiaryRecord(int id, String caption, String description, Date started, Date finished, int iduser) {
- this.id = id;
- this.caption = caption;
- this.description = description;
- this.started = started;
- this.finished = finished;
- this.iduser = iduser;
- }
- public String getCaption() {
- return caption;
- }
- public String getDescription() {
- return description;
- }
- public Date getFinished() {
- return finished;
- }
- public int getId() {
- return id;
- }
- public int getIduser() {
- return iduser;
- }
- public Date getStarted() {
- return started;
- }
- public void setCaption(String caption) {
- this.caption = caption;
- try
- {
- Statement stmt;
- Class.forName("com.mysql.jdbc.Driver");
- String url = "jdbc:mysql://localhost:3306/mysql";
- Connection con = DriverManager.getConnection(url,"root", "");
- System.out.println("URL: " + url); // debug
- System.out.println("Connection: " + con);
- stmt = con.createStatement();
- stmt.executeUpdate("UPDATE user SET caption = '"+caption+"' WHERE id='"+this.id+"'");
- con.close();
- }
- catch( Exception e )
- {
- System.out.println(e.getStackTrace()); // chyba
- }
- }
- public void setDescription(String description) {
- this.description = description;
- try
- {
- Statement stmt;
- Class.forName("com.mysql.jdbc.Driver");
- String url = "jdbc:mysql://localhost:3306/mysql";
- Connection con = DriverManager.getConnection(url,"root", "");
- System.out.println("URL: " + url); // debug
- System.out.println("Connection: " + con);
- stmt = con.createStatement();
- stmt.executeUpdate("UPDATE user SET description = '"+description+"' WHERE id='"+this.id+"'");
- con.close();
- }
- catch( Exception e )
- {
- System.out.println(e.getStackTrace()); // chyba
- }
- }
- public void setFinished(Date finished) {
- this.finished = finished;
- try
- {
- Statement stmt;
- Class.forName("com.mysql.jdbc.Driver");
- String url = "jdbc:mysql://localhost:3306/mysql";
- Connection con = DriverManager.getConnection(url,"root", "");
- System.out.println("URL: " + url); // debug
- System.out.println("Connection: " + con);
- stmt = con.createStatement();
- stmt.executeUpdate("UPDATE user SET finished = '"+finished+"' WHERE id='"+this.id+"'");
- con.close();
- }
- catch( Exception e )
- {
- System.out.println(e.getStackTrace()); // chyba
- }
- }
- public void setStarted(Date started) {
- this.started = started;
- try
- {
- Statement stmt;
- Class.forName("com.mysql.jdbc.Driver");
- String url = "jdbc:mysql://localhost:3306/mysql";
- Connection con = DriverManager.getConnection(url,"root", "");
- System.out.println("URL: " + url); // debug
- System.out.println("Connection: " + con);
- stmt = con.createStatement();
- stmt.executeUpdate("UPDATE user SET started = '"+started+"' WHERE id='"+this.id+"'");
- con.close();
- }
- catch( Exception e )
- {
- System.out.println(e.getStackTrace()); // chyba
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement