[queryviewer-devel] queryviewer/src/net/sourceforge/queryviewer Query.java,1.7,1.8
Status: Alpha
Brought to you by:
avdyk
From: Arnaud V. <av...@us...> - 2004-06-23 15:33:28
|
Update of /cvsroot/queryviewer/queryviewer/src/net/sourceforge/queryviewer In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28495 Modified Files: Query.java Log Message: changement du type de connexion. Maintenant, java.sql.Connection Index: Query.java =================================================================== RCS file: /cvsroot/queryviewer/queryviewer/src/net/sourceforge/queryviewer/Query.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Query.java 23 Jun 2004 11:43:23 -0000 1.7 --- Query.java 23 Jun 2004 15:33:20 -0000 1.8 *************** *** 1,4 **** - /* Created on 12-mai-2003 - */ package net.sourceforge.queryviewer; --- 1,2 ---- *************** *** 8,123 **** /** * Représente une requête et la connexion à la base de données. ! * * @author <a href="mailto:arn...@ul...">Arnaud Vandyck</a> * @version $Id$ */ ! public class Query extends PropertyChangeSupport { ! public static final String QUERY_PROPERTY = "query"; public static final String RESULT_PROPERTY = "result"; public static final String CONNECTION_PROPERTY = "connection"; ! ! private Connection connection; ! private String queryString; ! private String[][] result; ! ! /** ! * Constructeur par défaut. ! * @param connextion ! */ ! public Query( ) { ! super( Query.QUERY_PROPERTY ); ! } ! ! /** ! * Une requête ne se conçoit<b>-elle</b> que si une connexion est possible? ! * En fait, nous allons construire <b>une seule</b> requête, contrairement au modèle ! * que j'avais établi avant. Si la connexion se perd ou si une nouvelle connexion est établie, ! * il faudra utiliser la méthode {@link #setConnection(Connection)}. ! * @deprecated Utiliser le constructeur par défaut à la place. ! * @param connextion ! */ ! public Query( Connection connection ) { ! super( connection ); ! this.connection = connection; ! } ! ! /** ! * Une nouvelle requête est mise à jour <b>et</b> exécutée. Le résultat est prêt en appelant * la méthode {@link #getResult()} si aucune exception n'a été soulevée. ! * @param newQueryString la requête ! */ ! public void setQueryString(String newQueryString) throws QueryException { ! super.firePropertyChange( Query.QUERY_PROPERTY, this.queryString, newQueryString); ! this.queryString = newQueryString; ! // exécution de la requête String[][] res = this.performQuery(newQueryString); this.setResult( res ); ! } ! ! public String getQueryString() { ! return this.queryString; ! } ! ! /** ! * Retourne le résultat de la requête. ! * @return le résultat ! */ ! public String[][] getResult() { ! return result; ! } ! ! /** ! * Met à jour le résultat de la requête. ! * @param strings un tableau à deux dimensions de String ! */ ! protected void setResult(String[][] newResult) { ! super.firePropertyChange( Query.RESULT_PROPERTY, this.result, newResult); ! this.result = newResult; ! } ! ! /** ! * Exécution de la requête. Cet objet contient un objet Connection et peut donc exécuter une requête. ! * Le résultat de cette requête est à la fois envoyé à la méthode privée {@link #setResult(String[][])} ! * @see net.sourceforge.queryviewer.Connection#performQuery(net.sourceforge.queryviewer.Query) ! */ ! protected String[][] performQuery(String queryString) throws QueryException { ! String result[][] = null; ! if (this.connection==null) { throw new QueryException( "No connection available" ); ! } result = this.connection.performQuery(queryString); ! return result; ! } ! ! /** * Informations about the driver. ! * @deprecated Utiliser plutôt {@link #getConnection()}. ! * @see net.sourceforge.queryviewer.Connection#getInfo() ! */ ! public String getInfo() { String info = null; ! if (this.connection!=null) { info = this.connection.getInfo(); } ! return info; ! } ! /** * Met à jour la connexion. * @param newConnection la nouvelle connexion (null si fermeture de connexion). */ ! public void setConnection(Connection newConnection) { super.firePropertyChange( Query.CONNECTION_PROPERTY, this.connection, newConnection ); this.connection = newConnection; } ! /** * Retourne la connexion en cours. * @return la {@link Connection connexion} en cours. */ ! public Connection getConnection() { return this.connection; } ! } --- 6,129 ---- /** * Représente une requête et la connexion à la base de données. ! * * @author <a href="mailto:arn...@ul...">Arnaud Vandyck</a> * @version $Id$ */ ! public class Query extends PropertyChangeSupport ! { ! public static final String QUERY_PROPERTY = "query"; public static final String RESULT_PROPERTY = "result"; public static final String CONNECTION_PROPERTY = "connection"; ! ! private JDBCConnectionImpl connection; ! private String queryString; ! private String[][] result; ! ! /** ! * Constructeur par défaut. ! * @param connextion ! */ ! public Query( ) ! { ! super( Query.QUERY_PROPERTY ); ! } ! ! /** ! * Une nouvelle requète est mise à jour <b>et</b> exécutée. Le résultat est prêt en appelant * la méthode {@link #getResult()} si aucune exception n'a été soulevée. ! * @param newQueryString la requète ! */ ! public void setQueryString(String newQueryString) throws QueryException ! { ! super.firePropertyChange( Query.QUERY_PROPERTY, this.queryString, newQueryString); ! this.queryString = newQueryString; ! // exécution de la requète String[][] res = this.performQuery(newQueryString); this.setResult( res ); ! } ! ! public String getQueryString() ! { ! return this.queryString; ! } ! ! /** ! * Retourne le r?sultat de la requ?te. ! * @return le r?sultat ! */ ! public String[][] getResult() ! { ! return result; ! } ! ! /** ! * Met ? jour le r?sultat de la requ?te. ! * @param strings un tableau ? deux dimensions de String ! */ ! protected void setResult(String[][] newResult) ! { ! super.firePropertyChange( Query.RESULT_PROPERTY, this.result, newResult); ! this.result = newResult; ! } ! ! /** ! * Ex?cution de la requ?te. Cet objet contient un objet Connection et peut donc ex?cuter une requ?te. ! * Le r?sultat de cette requ?te est ? la fois envoy? ? la m?thode priv?e {@link #setResult(String[][])} ! * @see net.sourceforge.queryviewer.Connection#performQuery(net.sourceforge.queryviewer.Query) ! */ ! protected String[][] performQuery(String queryString) throws QueryException ! { ! String result[][] = null; ! if (this.connection==null) ! { throw new QueryException( "No connection available" ); ! } result = this.connection.performQuery(queryString); ! return result; ! } ! ! /** * Informations about the driver. ! * @deprecated Utiliser plut?t {@link #getConnection()}. ! * @see net.sourceforge.queryviewer.Connection#getInfo() ! */ ! public String getInfo() ! { String info = null; ! if (this.connection!=null) ! { info = this.connection.getInfo(); } ! return info; ! } ! /** * Met à jour la connexion. * @param newConnection la nouvelle connexion (null si fermeture de connexion). */ ! public void setConnection(JDBCConnectionImpl newConnection) ! { super.firePropertyChange( Query.CONNECTION_PROPERTY, this.connection, newConnection ); this.connection = newConnection; } ! /** * Retourne la connexion en cours. * @return la {@link Connection connexion} en cours. */ ! public Connection getConnection() ! { ! return this.connection.getConnection(); ! } ! ! /** ! * Retourne la connexion en cours. ! * @return la {@link Connection connexion} en cours. ! */ ! public JDBCConnectionImpl getJDBCConnection() ! { return this.connection; } ! } |