import java.net.*;
import java.sql.*;
import java.io.*;
import java.util.*;
class MakeDB
{
public static void main (String args[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // force loading of driver
String url = "jdbc:odbc:AMINO";
String user = "";
String password = "";
Connection con = DriverManager.getConnection(url,user,password);
Statement stmt = con.createStatement();
stmt.executeUpdate("CREATE TABLE AMINO_ABBREV (AMINO_NAME VARCHAR(25), ONE_LTR
VARCHAR(1), THREE_LTR VARCHAR(3))");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Alanine', 'A', 'Ala')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Arginine', 'R', 'Arg')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Asparigine', 'N',
'Asn')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Aspartic Acid', 'D',
'Asp')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Cysteine', 'C', 'Cys')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Glutamine', 'Q', 'Gln')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Glutamic Acid', 'E',
'Glu')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Glcyine', 'G', 'Gly')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Histidine', 'H', 'His')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Isoleucine', 'I',
'Ile')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Leucine', 'L', 'Leu')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Lysine', 'K', 'Lys')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Methionine', 'M',
'Met')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Phenylalanine', 'F',
'Phe')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Proline', 'P', 'Pro')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Serine', 'S', 'Ser')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Threonine', 'T', 'Thr')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Tryptophan', 'W',
'Trp')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Tyrosine', 'Y', 'Tyr')");
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Valine', 'V', 'Val')");
ResultSet aminoRS = stmt.executeQuery("SELECT AMINO_NAME, ONE_LTR, THREE_LTR
FROM AMINO_ABBREV");
System.out.println("**aminoRS created");
while(aminoRS.next())
{
String aminoName = aminoRS.getString("AMINO_NAME");
String oneLtr = aminoRS.getString("ONE_LTR");
String threeLtr = aminoRS.getString("THREE_LTR");
String spcr = " ";
System.out.println(aminoName + " " + oneLtr + " " + threeLtr);
}
System.out.println();
stmt.executeUpdate("INSERT INTO AMINO_ABBREV VALUES('Selenocysteine', 'U',
'Sec')");
aminoRS=stmt.executeQuery("SELECT AMINO_NAME, ONE_LTR, THREE_LTR FROM
AMINO_ABBREV");
while(aminoRS.next())
{
String aminoName = aminoRS.getString("AMINO_NAME");
String oneLtr = aminoRS.getString("ONE_LTR");
String threeLtr = aminoRS.getString("THREE_LTR");
String spcr = " ";
System.out.println(aminoName + " " + oneLtr + " " + threeLtr);
}
stmt.executeUpdate("CREATE TABLE AMINO_PROP (AMINO_NAME VARCHAR(25), MOL_WT
FLOAT)");
String updateStr = "UPDATE AMINO_PROP SET MOL_WT=? WHERE AMINO_NAME=?";
PreparedStatement ps = con.prepareStatement(updateStr);
String aminosAry[] = {"Alanine", "Arginine", "Asparigine", "Aspartic Acid",
"Cysteine", "Glutamine", "Glutamic Acid", "Glcyine", "Histidine", "Isoleucine", "Leucine",
"Lysine", "Methionine", "Phenylalanine", "Proline", "Serine", "Threonine", "Tryptophan",
"Tyrosine", "Valine"};
double molWtAry[] = {89.09, 174.20, 132.12, 133.10, 133.10, 146.15, 147.13,
75.07, 155.16, 155.16, 131.17, 146.19, 149.21, 165.19, 240.30, 105.09, 119.12, 204.23, 181.19,
117.15};
/*for (int stmtRep = 0; stmtRep < molWtAry.length; stmtRep++)
{
ps.setString(2, aminosAry[stmtRep]);
ps.setDouble(1, molWtAry[stmtRep]);
ps.executeUpdate();
}*/
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Alanine', 89.09)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Arginine', 174.20)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Asparigine', 132.12)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Aspartic Acid', 133.10)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Cysteine', 121.16)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Glutamine', 146.15)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Glutamic Acid', 147.13)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Glcyine', 75.07)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Histidine', 155.16)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Isoleucine', 131.17)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Leucine', 131.17)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Lysine', 146.19)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Methionine', 149.21)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Phenylalanine', 165.19)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Proline', 240.30)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Serine', 105.09)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Threonine', 119.12)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Tryptophan', 204.23)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Tyrosine', 181.19)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Valine', 117.15)");
stmt.executeUpdate("INSERT INTO AMINO_PROP VALUES('Selenocysteine', 168.05)");
System.out.println();
ResultSet molWtRS = stmt.executeQuery("SELECT AMINO_NAME, MOL_WT FROM
AMINO_PROP");
while(molWtRS.next())
{
String aminoName = molWtRS.getString("AMINO_NAME");
double molWt = molWtRS.getDouble("MOL_WT");
String spcr = " ";
System.out.println(aminoName + " " + molWt);
}
String combQ = "SELECT AMINO_ABBREV.AMINO_NAME, AMINO_ABBREV.ONE_LTR,
AMINO_ABBREV.THR_LTR, AMINO_PROP.MOL_WT FROM AMINO_ABBREV, AMINO_PROP WHERE
AMINO_ABBREV.AMINO_NAME = AMINO_PROP.AMINO_NAME";
System.out.println(combQ);
ResultSet aminoMolWtRS = stmt.executeQuery(combQ);
System.out.println("**ResultSet created");
while(aminoMolWtRS.next())
{
String aminoName = aminoRS.getString("AMINO_ABBREV.AMINO_NAME");
String oneLtr = aminoRS.getString("AMINO_ABBREV.ONE_LTR");
String threeLtr = aminoRS.getString("AMINO_ABBREV.THR_LTR");
double molWt = molWtRS.getDouble("AMINO_PROP.MOL_WT");
String spcr = " ";
System.out.println(aminoName + " " + oneLtr + " " + threeLtr + " " +
molWt);
}
stmt.close();
con.close();
}
catch (Exception ex)
{
System.out.println ("Exception "+ ex);
}
}
}