java - Accepting SQL Query in JSP Form -


what using: postgresql, netbeans, tomcat server, , jsp , html

to avoid question duplicate ia mtrying explain cleary :):

i connect jdbc driver database uni few tables. trying if user enters query in form

 please enter query: ............... 

like

select * student 

or

select distinct student.name student natural join transcript join professor using (pid) professor.name = 'artem'; 

or

select semester, year, count(distinct cid) numberofcourses transcript group ..., ... 

if user entered query should print out result. here stuck , not sure how implement java

if want can add code post. accessing database jsp

string query = request.getparameter("query"); if(query!=null && !"".equals(query)) {         connection con = new dbconnection().getconnection();         statement st = con.createstatement();         resultset rs = st.executequery(query);          resultsetmetadata rsmd = rs.getmetadata();         int  totalcolumn = rsmd.getcolumncount();           out.println("<table border='1' style='border-collapse:collapse'>");         out.println("<tr>");          for(int i=1;i<=totalcolumn;i++)         {             string columnname = rsmd.getcolumnname(i);             out.println("<th>"+columnname+"</th>");         }         out.println("</tr>");          while(rs.next())         {                 out.println("<tr>");             for(int col=1;col<=totalcolumn;col++)             {                             object obj= rs.getobject(col);                                     out.println("<td>"+ string.valueof(obj) +"</td>");             }              out.println("</tr>");         }         out.println("</table>"); } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -