Converted database connections to use JNDI naming over DriverManager connections. So LexConstantsSecure.java is no longer needed.

This commit is contained in:
dubtraxis 2003-10-06 16:19:11 +00:00
parent ee70f862c9
commit c532303425
2 changed files with 216 additions and 64 deletions

View file

@ -10,78 +10,217 @@ package org.thdl.lex;
public class LexConstants public class LexConstants
{ {
/* /*
* REQUEST PARAM/ATTR NAMES AND VALUES USED BY LexComponentFilter.java REQUEST PARAM/ATTR NAMES AND VALUES USED BY LexComponentFilter.java
*/ */
//form field req params //form field req params
/**
* Description of the Field
*/
public final static String LABEL_REQ_PARAM = "comp"; public final static String LABEL_REQ_PARAM = "comp";
/**
* Description of the Field
*/
public final static String TERMLABEL_VALUE = "term"; public final static String TERMLABEL_VALUE = "term";
/**
* Description of the Field
*/
public final static String PRONUNCIATIONLABEL_VALUE = "pronunciation"; public final static String PRONUNCIATIONLABEL_VALUE = "pronunciation";
/**
* Description of the Field
*/
public final static String SPELLINGLABEL_VALUE = "spelling"; public final static String SPELLINGLABEL_VALUE = "spelling";
/**
* Description of the Field
*/
public final static String ETYMOLOGYLABEL_VALUE = "etymology"; public final static String ETYMOLOGYLABEL_VALUE = "etymology";
/**
* Description of the Field
*/
public final static String FUNCTIONLABEL_VALUE = "function"; public final static String FUNCTIONLABEL_VALUE = "function";
/**
* Description of the Field
*/
public final static String ENCYCLOPEDIA_ARTICLE_LABEL_VALUE = "encyclopediaArticle"; public final static String ENCYCLOPEDIA_ARTICLE_LABEL_VALUE = "encyclopediaArticle";
/**
* Description of the Field
*/
public final static String DEFINITIONLABEL_VALUE = "definition"; public final static String DEFINITIONLABEL_VALUE = "definition";
/**
* Description of the Field
*/
public final static String SUBDEFINITIONLABEL_VALUE = "subdefinition"; public final static String SUBDEFINITIONLABEL_VALUE = "subdefinition";
/**
* Description of the Field
*/
public final static String MODELSENTENCELABEL_VALUE = "modelSentence"; public final static String MODELSENTENCELABEL_VALUE = "modelSentence";
/**
* Description of the Field
*/
public final static String PASSAGELABEL_VALUE = "passage"; public final static String PASSAGELABEL_VALUE = "passage";
/**
* Description of the Field
*/
public final static String TRANSLATIONLABEL_VALUE = "translationEquivalent"; public final static String TRANSLATIONLABEL_VALUE = "translationEquivalent";
/**
* Description of the Field
*/
public final static String RELATEDTERMLABEL_VALUE = "relatedTerm"; public final static String RELATEDTERMLABEL_VALUE = "relatedTerm";
/**
* Description of the Field
*/
public final static String REGISTERLABEL_VALUE = "register"; public final static String REGISTERLABEL_VALUE = "register";
/**
* Description of the Field
*/
public final static String KEYWORDLABEL_VALUE = "keyword"; public final static String KEYWORDLABEL_VALUE = "keyword";
/**
* Description of the Field
*/
public final static String PREFERENCESLABEL_VALUE = "preferences"; public final static String PREFERENCESLABEL_VALUE = "preferences";
/**
* Description of the Field
*/
public final static String ANALYTICALNOTELABEL_VALUE = "analyticalNote"; public final static String ANALYTICALNOTELABEL_VALUE = "analyticalNote";
/* /*
* REQUEST PARAM NAMES AND VALUES USED BY LexActionServlet.java REQUEST PARAM NAMES AND VALUES USED BY LexActionServlet.java
*/
/**
* Description of the Field
*/ */
public final static String COMMAND_REQ_PARAM = "cmd"; public final static String COMMAND_REQ_PARAM = "cmd";
/* /*
* REQUEST PARAM NAMES AND VALUES USED BY LoginServlet.java REQUEST PARAM NAMES AND VALUES USED BY LoginServlet.java
*/
/**
* Description of the Field
*/ */
public final static String USERNAME_REQ_PARAM = "username"; public final static String USERNAME_REQ_PARAM = "username";
/**
* Description of the Field
*/
public final static String PASSWORD_REQ_PARAM = "password"; public final static String PASSWORD_REQ_PARAM = "password";
/* /*
* -------------------------- --------------------------
* REQUEST PARAM NAMES USED BY LexComponent.scrapeRequest(req) METHODS REQUEST PARAM NAMES USED BY LexComponent.scrapeRequest(req) METHODS
* -------------------------- --------------------------
*/ */
//Meta Data Request Params //Meta Data Request Params
/**
* Description of the Field
*/
public final static String NOTE_REQ_PARAM = "note"; public final static String NOTE_REQ_PARAM = "note";
/**
* Description of the Field
*/
public final static String LANGUAGE_REQ_PARAM = "language"; public final static String LANGUAGE_REQ_PARAM = "language";
/**
* Description of the Field
*/
public final static String TRANSLATIONOF_REQ_PARAM = "translationOf"; public final static String TRANSLATIONOF_REQ_PARAM = "translationOf";
/**
* Description of the Field
*/
public final static String DIALECT_REQ_PARAM = "dialect"; public final static String DIALECT_REQ_PARAM = "dialect";
/**
* Description of the Field
*/
public final static String SOURCE_REQ_PARAM = "source"; public final static String SOURCE_REQ_PARAM = "source";
/**
* Description of the Field
*/
public final static String PROJSUB_REQ_PARAM = "projectSubject"; public final static String PROJSUB_REQ_PARAM = "projectSubject";
/**
* Description of the Field
*/
public final static String SCRIPT_REQ_PARAM = "script"; public final static String SCRIPT_REQ_PARAM = "script";
//Term Data Request Params //Term Data Request Params
/**
* Description of the Field
*/
public final static String TERM_REQ_PARAM = "term"; public final static String TERM_REQ_PARAM = "term";
/**
* Description of the Field
*/
public final static String TERMID_REQ_PARAM = "termId"; public final static String TERMID_REQ_PARAM = "termId";
// public static final String SPELLINGNOTE_REQ_PARAM = "spellingNote"; // public static final String SPELLINGNOTE_REQ_PARAM = "spellingNote";
/**
* Description of the Field
*/
public final static String PRECEDENCE_REQ_PARAM = "precedence"; public final static String PRECEDENCE_REQ_PARAM = "precedence";
//Definition Data Request Params //Definition Data Request Params
/**
* Description of the Field
*/
public final static String SUBDEFINITION_REQ_PARAM = "subdefinition"; public final static String SUBDEFINITION_REQ_PARAM = "subdefinition";
//outgoing request attributes to jsp //outgoing request attributes to jsp
/**
* Description of the Field
*/
public final static String COMPONENT_REQ_ATTR = "component"; public final static String COMPONENT_REQ_ATTR = "component";
/**
* Description of the Field
*/
public final static String ORIGINALBEAN_REQ_ATTR = "original"; public final static String ORIGINALBEAN_REQ_ATTR = "original";
/**
* Description of the Field
*/
public final static String MESSAGE_REQ_ATTR = "message"; public final static String MESSAGE_REQ_ATTR = "message";
//session attributes used by filters, servlet, commands and jsp //session attributes used by filters, servlet, commands and jsp
/**
* Description of the Field
*/
public final static String USER_SESS_ATTR = "user"; public final static String USER_SESS_ATTR = "user";
/**
* Description of the Field
*/
public final static String PREFERENCES_SESS_ATTR = "preferences"; public final static String PREFERENCES_SESS_ATTR = "preferences";
/**
* Description of the Field
*/
public final static String LOGINTARGET_SESS_PARAM = "loginTarget"; public final static String LOGINTARGET_SESS_PARAM = "loginTarget";
/**
* Description of the Field
*/
public final static String DISPLAYMODE_SESS_ATTR = "displayMode"; public final static String DISPLAYMODE_SESS_ATTR = "displayMode";
/**
* Description of the Field
*/
public final static String QUERY_SESS_ATTR = "query"; public final static String QUERY_SESS_ATTR = "query";
/**
* Description of the Field
*/
public final static String TERMENTRYBEAN_SESS_ATTR = "termEntry"; public final static String TERMENTRYBEAN_SESS_ATTR = "termEntry";
//used by Servlet //used by Servlet
/**
* Description of the Field
*/
public final static String JSP_DIR = "/jsp/"; public final static String JSP_DIR = "/jsp/";
/**
* Description of the Field
*/
public final static String WELCOME_PAGE = "action?cmd=menu"; public final static String WELCOME_PAGE = "action?cmd=menu";
/**
* Description of the Field
*/
public final static String ERROR_PAGE = "error.jsp"; public final static String ERROR_PAGE = "error.jsp";
//used by Repository //used by Repository
/**
* Description of the Field
*/
public final static String DRIVER = "com.mysql.jdbc.Driver"; public final static String DRIVER = "com.mysql.jdbc.Driver";
/**
* Description of the Field
*/
public final static String DATASOURCE_NAME = "java:comp/env/jdbc/lex-datasource";
/**
* Description of the Field
*/
public final static String HIBERNATE_SESSION_KEY = "hib"; public final static String HIBERNATE_SESSION_KEY = "hib";
//public final static String URL = "jdbc:mysql://localhost/LexTorque"; //public final static String URL = "jdbc:mysql://localhost/LexTorque";

View file

@ -1,7 +1,9 @@
package org.thdl.lex; package org.thdl.lex;
import java.sql.*;
import java.util.*; import java.util.*;
import java.sql.*; import javax.naming.*;
import javax.sql.*;
/** /**
@ -129,7 +131,7 @@ public class LexRepository
} }
catch ( SQLException sqle ) catch ( SQLException sqle )
{ {
throw new LexRepositoryException( sqle.getMessage() ); throw new LexRepositoryException( sqle );
} }
} }
@ -150,7 +152,7 @@ public class LexRepository
} }
catch ( SQLException sqle ) catch ( SQLException sqle )
{ {
throw new LexRepositoryException( sqle.getMessage() ); throw new LexRepositoryException( sqle );
} }
} }
@ -197,7 +199,7 @@ public class LexRepository
} }
catch ( SQLException sqle ) catch ( SQLException sqle )
{ {
throw new LexRepositoryException( sqle.getMessage() ); throw new LexRepositoryException( sqle );
} }
} }
@ -300,6 +302,7 @@ public class LexRepository
{ {
try try
{ {
/*
Class.forName( LexConstants.DRIVER ); Class.forName( LexConstants.DRIVER );
Properties props = new Properties(); Properties props = new Properties();
props.setProperty( "user", LexConstantsSecure.USER ); props.setProperty( "user", LexConstantsSecure.USER );
@ -307,16 +310,26 @@ public class LexRepository
props.setProperty( "useUnicode", "true" ); props.setProperty( "useUnicode", "true" );
props.setProperty( "characterEncoding", "UTF-8" ); props.setProperty( "characterEncoding", "UTF-8" );
setConnection( DriverManager.getConnection( LexConstantsSecure.URL, props ) ); setConnection( DriverManager.getConnection( LexConstantsSecure.URL, props ) );
*/
Context context = new InitialContext();
DataSource source = (DataSource) context.lookup( LexConstants.DATASOURCE_NAME );
setConnection( source.getConnection() );
setQueryStatement( getConnection().createStatement() ); setQueryStatement( getConnection().createStatement() );
setUpdateStatement( getConnection().createStatement() ); setUpdateStatement( getConnection().createStatement() );
} }
/*
catch ( ClassNotFoundException cnfe ) catch ( ClassNotFoundException cnfe )
{ {
throw new LexRepositoryException( "No Driver Available for: " + LexConstants.DRIVER ); throw new LexRepositoryException( "No Driver Available for: " + LexConstants.DRIVER );
} }
*/
catch ( NamingException ne )
{
throw new LexRepositoryException( ne );
}
catch ( SQLException se ) catch ( SQLException se )
{ {
throw new LexRepositoryException( se.getMessage() ); throw new LexRepositoryException( se );
} }
} }
} }