
import java.sql.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class Prepare
{
	public static void main(String[] argv) throws IOException, SQLException
	{
		Connection c = null;

		try
		{
			c = getConnection();

			PreparedStatement s = c.prepareStatement("INSERT INTO actor (id,name) VALUES (?,?);");

			s.setInt(1, 100000);
			s.setString(2, "Test");

			int count = s.executeUpdate();
			System.out.println(count + " rows inserted.");

			s.close();

		} catch (SQLException e)
		{
			System.err.println("SQLException: " + e.getMessage());
			System.exit(1);
		} finally
		{
			c.close();
		}
	}

	public static Connection getConnection() throws SQLException, IOException  
	{    
		Properties props = new Properties();  
		FileInputStream in = new FileInputStream("database.properties");  
		props.load(in);  
		in.close();  

		String drivers = props.getProperty("jdbc.drivers");  

		if (drivers != null)  
			System.setProperty("jdbc.drivers", drivers);  

		String url = props.getProperty("jdbc.url");  
		String username = props.getProperty("jdbc.username");  
		String password = props.getProperty("jdbc.password");  

		return DriverManager.getConnection(url, username, password);  
	}  
}

