/* * AdminInsert.java * Author: Song Qian * Created on February 21, 2004, 7:16 PM */ package museum; import java.beans.*; import java.sql.*; /** *

Title: AdminInsety.java

*

Description: Insert / Modify photo to database

*

Copyright: Copyright (c) 2004

*

Company: Song Qian

* @author Song Qian * @version 1.3 */ public class AdminInsert extends Object implements java.io.Serializable { // private String cat; // private String subCat; private String name = ""; private String url = ""; private String description = ""; private int id = 0; private String strId = "0"; private SQLManager database; private ResultSet rs; // SQL ResultSet /** Creates new DBConn */ public AdminInsert() throws SQLException { database = new SQLManager(); } public boolean isValid() { if ( name.length()<1 || url.length()<1 ) return false; return true; } /* public boolean isValidInt( String iString ) { try { Integer.parseInt( iString ); return true; } catch( NumberFormatException e ) { return false; } } */ public int doInsert() throws SQLException { String sqlQuery = "INSERT INTO ethnobot VALUES ('','','','" + name + "','" + url + "','" + description + "')"; return database.executeUpdate( sqlQuery ); } public int doModify() throws SQLException { String sqlQuery = "UPDATE ethnobot SET name=\"" + name + "\", url=\"" + url + "\", description=\"" + description + "\" WHERE id=\'" + id + "\'"; return database.executeUpdate( sqlQuery ); } public ResultSet getID() throws SQLException { rs = database.executeQuery( "SELECT * FROM ethnobot WHERE id=\"" + id + "\"" ); return rs; } /* public String getCat() { return cat; } public void setCat( String iCat ) { cat = iCat; if ( cat != null ) cat = cat.trim(); } public String getSubCat() { return subCat; } public void setSubCat( String iSubCat ) { subCat = iSubCat; if ( subCat != null ) subCat = subCat.trim(); } */ public String getName() { return name; } public void setName( String iName ) { name = iName; if ( name != null ) name = name.trim(); else name = ""; } public String getUrl() { return url; } public void setUrl( String iUrl ) { url = iUrl; if ( url != null ) url = url.trim(); else url = ""; } public String getDescription() { return description; } public void setDescription( String iDescription ) { description = iDescription; if ( description != null ) description = description.trim(); else description = ""; } public void setStrId( String iStrId ) { strId = iStrId; if ( strId == null ) strId = "0"; try { id = Integer.parseInt( strId ); } catch( NumberFormatException e ) { id = 0; } } public String getStrId() { return strId; } public int getId() { return id; } }