Masz kawałek mojej klasy do wykonywania skryptów
private void wykonaj()
{
String[] commands=question.getText().split(";");
try
{
for (int i=0;i<commands.length;i++)
{
String polecenie=commands[i].replaceAll("\n","")+";\n";
if (!polecenie.startsWith(";"))
{
st.execute(polecenie);
}
}
conn.commit();
answer.setText("Sukces");
}
catch (SQLException e)
{
try
{
conn.rollback();
}
catch (SQLException ex)
{
answer.append("\n"+e.getMessage());
}
answer.setText("Błąd: "+e.getMessage());
while ((e=e.getNextException())!=null)
{
answer.append("\n"+e.getMessage());
}
}
}
question jest typu JTextArea, użytkownik może tam napisać skrypt lub wczytać go z pliku
conn jest klasy Connection
st jest klasy Statement
conn.setAutoCommit(false);
st=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
</quote>