package k1; import k1.*; import java.sql.*; public class Baasiuba1{ Connection cn; Statement st; public Baasiuba1(){ try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); cn=DriverManager.getConnection("jdbc:odbc:baas1", "", ""); st=cn.createStatement(); }catch(Exception e){ System.out.println(e); } } public void looBaas() throws SQLException{ String lause="CREATE TABLE pallid (kogus int);"; st.executeUpdate(lause); lause="INSERT INTO pallid (kogus) values ('0');"; st.executeUpdate(lause); } public void setPalliarv(int arv) throws SQLException{ String lause="UPDATE pallid SET kogus="+arv+";"; st.executeUpdate(lause); } public int getPalliarv() throws SQLException{ String lause="SELECT kogus FROM pallid;"; ResultSet rs=st.executeQuery(lause); rs.next(); return rs.getInt("kogus"); } }