public class MySQL extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String user = "100_fritz"; String pass = "freeyxy"; try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/100_java", user, pass); Statement st = con.createStatement(); String table = "CREATE TABLE java_DataTypes2(typ_boolean BOOL, " + "typ_byte TINYINT, typ_short SMALLINT, " + "typ_int INTEGER, typ_long BIGINT, " + "typ_float FLOAT, typ_double DOUBLE PRECISION, " + "typ_bigdecimal DECIMAL(13,0), typ_string VARCHAR(254), " + "typ_date DATE, typ_time TIME, " + "typ_timestamp TIMESTAMP, " + "typ_asciistream TEXT, typ_binarystream LONGBLOB, " + "typ_blob BLOB)"; st.executeUpdate(table); con.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { } /* PrintWriter writer = response.getWriter(); writer.println("<html>"); writer.println("<head><title>Hello World Servlet</title></head>"); writer.println("<body>"); writer.println(" <h1>Hello World from a Sevlet!</h1>"); writer.println("<body>"); writer.println("</html>"); writer.close(); */ } } |