开发者

How do I call this Createquery.java file from a jsp page that has OpenLayers integrated in it?

package database;


    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import da开发者_运维百科tabase.Dbconnect;

    public class CreateQuery {
        Connection conn;

        public CreateQuery() throws ClassNotFoundException, SQLException, IOException {
            conn=new Dbconnect().returnDatabaseConnection();
        }
        public int addNewLayertoDB(String feature_name,String shape,int Latitude , int Longitude , int feature_geom , String feature_details){
            try {
                PreparedStatement statement = null;
                String table_name = feature_name + "_" + shape; 
                String query = "CREATE TABLE EtherMap "+table_name+" ("+ feature_name+" (20))";
                statement = conn.prepareStatement(query);
                statement.setString(1, feature_name);
                statement.execute();
                String squery = "ALTER TABLE EtherMap" +table_name+"  ADD COLUMN geom int , ADD COLUMN shape character(10)";
                return 1;
                } catch (SQLException ex) {
                return 0;
            }
        }




        public void closeConn() throws SQLException {
            if (conn != null) {
                this.conn.close();
            }
        }

    }

I have coded this createquery.java code which would create a table in postgres . I need to call it when I draw anything on a open layers map , using javascript in a jsp page . How do I call it ? Do I have to use the beans ?


It would be good design if you call it from servlet and servlet from jsp taking user input


See Also

  • Servlet


  • Make a request to your server, on a specific URL, probably using JavaScript
  • Map that URL to a specific Servlet
  • Code your servlet to execute whatever method, you like, of your class

Simple, isn't it?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜