Skip to content
Snippets Groups Projects
Commit 45c34f0e authored by tjc's avatar tjc
Browse files

write sql log

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@2814 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 52f5a584
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ import java.sql.*; ...@@ -28,6 +28,7 @@ import java.sql.*;
import java.io.*; import java.io.*;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Vector; import java.util.Vector;
import java.util.Date;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
/** /**
...@@ -43,6 +44,8 @@ public class DatabaseDocument extends Document ...@@ -43,6 +44,8 @@ public class DatabaseDocument extends Document
private InputStreamProgressListener progress_listener; private InputStreamProgressListener progress_listener;
private Hashtable db; private Hashtable db;
private Vector organism; private Vector organism;
private String sqlLog = System.getProperty("user.home")+
System.getProperty("file.separator")+"art_sql.log";
/** /**
* *
...@@ -179,8 +182,8 @@ public class DatabaseDocument extends Document ...@@ -179,8 +182,8 @@ public class DatabaseDocument extends Document
" and featureloc.feature_id=feature.feature_id" + " and featureloc.feature_id=feature.feature_id" +
" and feature.type_id=cvterm.cvterm_id and cvterm.name='gene'"; " and feature.type_id=cvterm.cvterm_id and cvterm.name='gene'";
appendToLogFile(sql,sqlLog);
ResultSet rs = st.executeQuery(sql); ResultSet rs = st.executeQuery(sql);
StringBuffer cdsBuffer = new StringBuffer(); StringBuffer cdsBuffer = new StringBuffer();
int loop = 1; int loop = 1;
...@@ -230,6 +233,8 @@ public class DatabaseDocument extends Document ...@@ -230,6 +233,8 @@ public class DatabaseDocument extends Document
if(cv_name != null) if(cv_name != null)
sql = sql + " AND cv.name='"+cv_name+"'"; sql = sql + " AND cv.name='"+cv_name+"'";
appendToLogFile(sql,sqlLog);
cvterm = new Hashtable(); cvterm = new Hashtable();
try try
...@@ -265,6 +270,8 @@ public class DatabaseDocument extends Document ...@@ -265,6 +270,8 @@ public class DatabaseDocument extends Document
String sql = "SELECT name, residues from feature where feature_id = '"+ String sql = "SELECT name, residues from feature where feature_id = '"+
feature_id+"'"; feature_id+"'";
appendToLogFile(sql,sqlLog);
ResultSet rs = st.executeQuery(sql); ResultSet rs = st.executeQuery(sql);
rs.next(); rs.next();
...@@ -290,16 +297,23 @@ public class DatabaseDocument extends Document ...@@ -290,16 +297,23 @@ public class DatabaseDocument extends Document
Statement st = conn.createStatement(); Statement st = conn.createStatement();
String sql = "select cvterm.cvterm_id, cvterm.name FROM cvterm, cv "+ String sql = "select type_id from feature where residues notnull";
"WHERE cv.cv_id = cvterm.cv_id and cvterm.name = 'region'"; appendToLogFile(sql,sqlLog);
ResultSet rs = st.executeQuery(sql);
ResultSet rs = st.executeQuery(sql);
rs.next(); rs.next();
String cvterm_id = rs.getString("cvterm_id"); String cvterm_id = rs.getString("type_id");
// String sql = "select cvterm.cvterm_id, cvterm.name FROM cvterm, cv "+
// "WHERE cv.cv_id = cvterm.cv_id and cvterm.name = 'chromosome'";
// ResultSet rs = st.executeQuery(sql);
// rs.next();
// String cvterm_id = rs.getString("cvterm_id");
sql = new String("SELECT abbreviation, name, feature_id FROM organism, feature WHERE type_id = '"+ sql = new String("SELECT abbreviation, name, feature_id FROM organism, feature WHERE type_id = '"+
cvterm_id+"' and organism.organism_id=feature.organism_id "+ cvterm_id+"' and organism.organism_id=feature.organism_id "+
"ORDER BY abbreviation, name"); "ORDER BY abbreviation, name");
appendToLogFile(sql,sqlLog);
rs = st.executeQuery(sql); rs = st.executeQuery(sql);
while(rs.next()) while(rs.next())
...@@ -351,5 +365,39 @@ public class DatabaseDocument extends Document ...@@ -351,5 +365,39 @@ public class DatabaseDocument extends Document
throw new ReadOnlyException ("this Database Document can not be written to"); throw new ReadOnlyException ("this Database Document can not be written to");
} }
/**
*
* Appends a log entry to the log file
* @param logEntry entry to add to log file
* @param logFileName log file name
*
*/
private void appendToLogFile(String logEntry, String logFileName)
{
BufferedWriter bw = null;
try
{
String dat = new java.util.Date().toString();
bw = new BufferedWriter(new FileWriter(dat+":: "+logFileName, true));
bw.write(logEntry);
bw.newLine();
bw.flush();
}
catch (Exception ioe)
{
System.out.println("Error writing to log file "+logFileName);
ioe.printStackTrace();
}
finally // always close the file
{
if(bw != null)
try
{
bw.close();
}
catch (IOException ioe2) {}
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment