atf = new DatabaseLoader(); atf.setOptions(options); atf.setSource(atf.getUrl(), atf.getUser(), atf.getPassword()); if (!atf.m_inc) { System.out.println(atf.getDataSet()); } else { Instances structure = atf.getStructure(); System.out.println(structure); Instance temp; do { temp = atf.getNextInstance(structure); if (temp != null) { System.out.println(temp);
/** * Sets the database user * * @param user the database user name */ @Override public void setUser(String user) { checkEnv(); m_User = user; String userCopy = user; try { userCopy = m_env.substitute(userCopy); } catch (Exception ex) { } m_DataBaseConnection.setUsername(userCopy); }
if (getRetrieval() == BATCH) { throw new IOException( "Cannot mix getting Instances in both incremental and batch modes"); setRetrieval(INCREMENTAL); if (m_datasetPseudoInc.numInstances() > 0) { Instance current = m_datasetPseudoInc.instance(0); return current; } else { resetStructure(); return null; setRetrieval(INCREMENTAL); try { if (!m_DataBaseConnection.isConnected()) { connectToDatabase(); if (!checkForKey()) { throw new Exception( "A unique order cannot be detected automatically.\nYou have to use SELECT * in your query to enable this feature.\nMaybe JDBC driver is not able to detect key.\nDefine primary key in your database or use -P option (command line) or enter key columns in the GUI."); m_rowCount = getRowCount(); if (m_DataBaseConnection.execute(limitQuery(m_query, m_counter, m_choice)) == false) { throw new Exception("Tuple could not be retrieved."); ResultSet rs = m_DataBaseConnection.getResultSet();
if ((getUrl() != null) && (getUrl().length() != 0)) { options.add("-url"); options.add(getUrl()); if ((getUser() != null) && (getUser().length() != 0)) { options.add("-user"); options.add(getUser()); if ((getPassword() != null) && (getPassword().length() != 0)) { options.add("-password"); options.add(getPassword()); options.add(getQuery());
private boolean resetAndUpdateDatabaseLoaderIfChanged() { DatabaseLoader dbl = (DatabaseLoader) m_dsLoader.getLoader(); String url = dbl.getUrl(); String user = dbl.getUser(); String password = dbl.getPassword(); String query = dbl.getQuery(); String keys = dbl.getKeys(); File propsFile = dbl.getCustomPropsFile(); dbl.resetStructure(); dbl.setUrl(m_dbaseURLText.getText()); dbl.setUser(m_userNameText.getText()); dbl.setPassword(new String(m_passwordText.getPassword())); dbl.setQuery(m_queryText.getText()); dbl.setKeys(m_keyText.getText()); if (m_dbProps.getText() != null && m_dbProps.getText().length() > 0) { dbl.setCustomPropsFile(new File(m_dbProps.getText()));
connectToDatabase(); pseudo: try { if (m_pseudoIncremental && m_structure == null) { if (getRetrieval() == BATCH) { throw new IOException( "Cannot mix getting instances in both incremental and batch modes"); setRetrieval(NONE); m_datasetPseudoInc = getDataSet(); m_structure = new Instances(m_datasetPseudoInc, 0); setRetrieval(NONE); return m_structure; if (!m_DataBaseConnection.tableExists(endOfQuery(true))) { throw new IOException( "Table does not exist according to metadata from JDBC driver. " while (!rightChoice) { try { String limitQ = limitQuery(m_query, 0, choice); if (m_DataBaseConnection.execute(limitQ) == false) { throw new IOException("Query didn't produce results"); String end = endOfQuery(false); ResultSet rs = m_DataBaseConnection.getResultSet(); if (getRetrieval() != INCREMENTAL) { attributeTypes[i - 1] = Attribute.STRING; break;
DatabaseLoader dbl = new DatabaseLoader(); dbl.setUser(user); dbl.setPassword(password); dbl.setUrl(uRL); dbl.setQuery(query);
throw new IOException("No source database has been specified"); if (getRetrieval() == INCREMENTAL) { throw new IOException( "Cannot mix getting Instances in both incremental and batch modes"); setRetrieval(BATCH); checkEnv(); try { InstanceQuery iq = new InstanceQuery(); printException(ex); StringBuffer text = new StringBuffer(); if (m_query.equals("Select * from Results0")) { text.append("\n\nDatabaseLoader options:\n"); Enumeration<Option> enumi = listOptions();
.getPassword()); JPanel passwordHolder = new JPanel(); passwordHolder.setLayout(new BorderLayout()); m_queryText.setText(((DatabaseLoader) m_dsLoader.getLoader()).getQuery()); gbConstraints = new GridBagConstraints(); gbConstraints.anchor = GridBagConstraints.EAST; m_keyText.setText(((DatabaseLoader) m_dsLoader.getLoader()).getKeys()); gbConstraints = new GridBagConstraints(); gbConstraints.anchor = GridBagConstraints.EAST; gbLayout.setConstraints(m_dbProps, gbConstraints); db.add(m_dbProps); File toSet = ((DatabaseLoader) m_dsLoader.getLoader()).getCustomPropsFile(); if (toSet != null) { m_dbProps.setText(toSet.getPath());
/** * Counts the number of rows that are loaded from the database * * @throws Exception if the number of rows cannot be calculated * @return the entire number of rows */ private int getRowCount() throws Exception { String query = "SELECT COUNT(*) FROM " + endOfQuery(false); if (m_DataBaseConnection.execute(query) == false) { throw new Exception("Cannot count results tuples."); } ResultSet rs = m_DataBaseConnection.getResultSet(); rs.next(); int i = rs.getInt(1); rs.close(); return i; }
private boolean resetAndUpdateDatabaseLoaderIfChanged() { DatabaseLoader dbl = (DatabaseLoader) m_dsLoader.getLoader(); String url = dbl.getUrl(); String user = dbl.getUser(); String password = dbl.getPassword(); String query = dbl.getQuery(); String keys = dbl.getKeys(); File propsFile = dbl.getCustomPropsFile(); dbl.resetStructure(); dbl.setUrl(m_dbaseURLText.getText()); dbl.setUser(m_userNameText.getText()); dbl.setPassword(new String(m_passwordText.getPassword())); dbl.setQuery(m_queryText.getText()); dbl.setKeys(m_keyText.getText()); if (m_dbProps.getText() != null && m_dbProps.getText().length() > 0) { dbl.setCustomPropsFile(new File(m_dbProps.getText()));
connectToDatabase(); pseudo: try { if (m_pseudoIncremental && m_structure == null) { if (getRetrieval() == BATCH) { throw new IOException( "Cannot mix getting instances in both incremental and batch modes"); setRetrieval(NONE); m_datasetPseudoInc = getDataSet(); m_structure = new Instances(m_datasetPseudoInc, 0); setRetrieval(NONE); return m_structure; if (!m_DataBaseConnection.tableExists(endOfQuery(true))) { throw new IOException( "Table does not exist according to metadata from JDBC driver. " while (!rightChoice) { try { String limitQ = limitQuery(m_query, 0, choice); if (m_DataBaseConnection.execute(limitQ) == false) { throw new IOException("Query didn't produce results"); String end = endOfQuery(false); ResultSet rs = m_DataBaseConnection.getResultSet(); if (getRetrieval() != INCREMENTAL) { attributeTypes[i - 1] = Attribute.STRING; break;
DatabaseLoader dbl = new DatabaseLoader(); dbl.setUser(user); dbl.setPassword(password); dbl.setUrl(uRL); dbl.setQuery(query);
throw new IOException("No source database has been specified"); if (getRetrieval() == INCREMENTAL) { throw new IOException( "Cannot mix getting Instances in both incremental and batch modes"); setRetrieval(BATCH); checkEnv(); try { InstanceQuery iq = new InstanceQuery(); printException(ex); StringBuffer text = new StringBuffer(); if (m_query.equals("Select * from Results0")) { text.append("\n\nDatabaseLoader options:\n"); Enumeration<Option> enumi = listOptions();
if ((getUrl() != null) && (getUrl().length() != 0)) { options.add("-url"); options.add(getUrl()); if ((getUser() != null) && (getUser().length() != 0)) { options.add("-user"); options.add(getUser()); if ((getPassword() != null) && (getPassword().length() != 0)) { options.add("-password"); options.add(getPassword()); options.add(getQuery());
.getPassword()); JPanel passwordHolder = new JPanel(); passwordHolder.setLayout(new BorderLayout()); m_queryText.setText(((DatabaseLoader) m_dsLoader.getLoader()).getQuery()); gbConstraints = new GridBagConstraints(); gbConstraints.anchor = GridBagConstraints.EAST; m_keyText.setText(((DatabaseLoader) m_dsLoader.getLoader()).getKeys()); gbConstraints = new GridBagConstraints(); gbConstraints.anchor = GridBagConstraints.EAST; gbLayout.setConstraints(m_dbProps, gbConstraints); db.add(m_dbProps); File toSet = ((DatabaseLoader) m_dsLoader.getLoader()).getCustomPropsFile(); if (toSet != null) { m_dbProps.setText(toSet.getPath());
/** * Counts the number of rows that are loaded from the database * * @throws Exception if the number of rows cannot be calculated * @return the entire number of rows */ private int getRowCount() throws Exception { String query = "SELECT COUNT(*) FROM " + endOfQuery(false); if (m_DataBaseConnection.execute(query) == false) { throw new Exception("Cannot count results tuples."); } ResultSet rs = m_DataBaseConnection.getResultSet(); rs.next(); int i = rs.getInt(1); rs.close(); return i; }
atf = new DatabaseLoader(); atf.setOptions(options); atf.setSource(atf.getUrl(), atf.getUser(), atf.getPassword()); if (!atf.m_inc) { System.out.println(atf.getDataSet()); } else { Instances structure = atf.getStructure(); System.out.println(structure); Instance temp; do { temp = atf.getNextInstance(structure); if (temp != null) { System.out.println(temp);
if (getRetrieval() == BATCH) { throw new IOException( "Cannot mix getting Instances in both incremental and batch modes"); setRetrieval(INCREMENTAL); if (m_datasetPseudoInc.numInstances() > 0) { Instance current = m_datasetPseudoInc.instance(0); return current; } else { resetStructure(); return null; setRetrieval(INCREMENTAL); try { if (!m_DataBaseConnection.isConnected()) { connectToDatabase(); if (!checkForKey()) { throw new Exception( "A unique order cannot be detected automatically.\nYou have to use SELECT * in your query to enable this feature.\nMaybe JDBC driver is not able to detect key.\nDefine primary key in your database or use -P option (command line) or enter key columns in the GUI."); m_rowCount = getRowCount(); if (m_DataBaseConnection.execute(limitQuery(m_query, m_counter, m_choice)) == false) { throw new Exception("Tuple could not be retrieved."); ResultSet rs = m_DataBaseConnection.getResultSet();
DatabaseLoader dbl = new DatabaseLoader(); dbl.setUser(user); dbl.setPassword(password); dbl.setUrl(uRL); dbl.setQuery(query);