package ru.k0r0tk0ff.main;

import java.sql.*;

/**
 * Class for connect to db, and generate xml file from db's data
 *
 */

public class XmlGenerator {

	PreparedStatement preparedStatement = null;
	Connection connection = null;
	String sqlQuery = "SELECT * FROM TEST";

	void getDataFromDbAndGenerateXmlFile(String url, String login, String password, int n) {

		try {
			connection = DriverManager.getConnection(
					url,
					login,
					password);

			// Try drop table, if exist

			try {
				preparedStatement = connection.prepareStatement(sqlQuery);
				ResultSet resultSet = preparedStatement.executeQuery();
				System.out.println("Select success !!!");
			} catch (SQLException sqlErrorForDropTable){
				System.out.println("Select failed !!!");
				sqlErrorForDropTable.printStackTrace();
			}

		} catch (SQLException e) {
			System.out.println("Connection Failed! Check output console");
			e.printStackTrace();
		}

	}

	void closeConnection() {
		try {
			connection.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

}

@@ -653,24 +653,206 @@
 ccess !!!%22);
+%0A%0A%09%09%09%09//for debug - need to see result of sql query%0A%09%09%09%09// resultSet.getInt(1) - 1 is column index%0A%0A%09%09%09%09while (resultSet.next()) %7B%0A%09%09%09%09%09System.out.println(resultSet.getInt(1));%0A%09%09%09%09%7D
 %0A%09%09%09%7D catch 
@@ -1231,8 +1231,12 @@
 %7D%0A%09%7D%0A%0A%7D%0A
+%0A%0A%0A%0A

add dbInserter.closeConnection()