Jump to content

aristal

Members
  • Posts

    5
  • Joined

  • Last visited

aristal's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. May i know what u mean by plugging? Does it mean that i have to install additional things?
  2. Hi,I really need some help here...I need to pass selected information from my database to another information.I am able to select and display the infotmation but i am not sure how i can transfer the information to the next program. Can any one please offer me some assistance?My code is as follow: /* Getting data from PSM32 and displaying it *can work* */import java.net.URL;import java.sql.*;import java.lang.String;/** Application to create a Ganttchart * */public class PSMdb{public static void main (String argv[]){//SQLQueryFormat a = new SQLQueryFormat();System.out.println("\nEstablishing Connection - Pls Wait... \n");/** Get Info fr database**/try{ //Connect to the database specified in the URL Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:PSM32"); System.out.println("Connection Established.\n"); //Create a SELECT statement object Statement statmt = con.createStatement(); //Issue the SELECT statement String querySt = "SELECT Set, Name, Order " + "FROM PMETERS " + "WHERE Set = 'BRAKE.BAK' "; //Create and execute query ResultSet res = statmt.executeQuery(querySt); while (res.next()) { String Proj = res.getString(1); //get Proj Name String Task = res.getString(2); //get Task Name //Print statement System.out.println("" +Proj); System.out.println("" +Task); } //Close Statement and Connection statmt.close(); con.close(); System.out.println("\nConnection Closed - Operation Successful.");} catch(Exception E){//Print out the Exception ErrorSystem.out.println("Error:" +E );}}} And yes there is another problem. I can compile and run the program in a C:\folder but when i open the document in a project workspace, i cant compile the above code. Can any one please offer me assistance?Thanks a million.
  3. Hi,I manage to display the code u gave. Can someone please give me some advise on what i should do next.Thank you
  4. I was told to post my problem here. Can anyone offer me assistance?I have a servlet "Login.java" that is directed to different url depending on the login domain.The login jsp is in "Tomcat 5.5\webapps\FYP" folder and the directed pages are in the "Tomcat 5.5\webapps\FYP\WEB-INF\classes" folder.When i try to login using tomcat as the server, I get the following error."HTTP method GET is not supported by this URL.description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL)."The servlet code is as follow:import java.sql.*;import java.io.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*; public class Login extends HttpServlet{public void service (String gotoPage, HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException { //Get current session or create new oneHttpSession session = req.getSession(true); //Get login infoString Domain = req.getParameter("Domain");String username = req.getParameter("username");String password = req.getParameter("password"); PrintWriter out = res.getWriter(); try{System.out.println("\nEstablishing Connection - Pls Wait... \n"); //Connect to the database specified in the URLClass.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection con = DriverManager.getConnection("jdbc:odbc:DB1");System.out.println("Connection Established.\n"); //Create a SELECT statement objectStatement statmt = con.createStatement(); /*For COntractor*/if (Domain.equals("Contractor")){//Issue the SELECT statementString querySt = "SELECT Engineer_Name, FROM Organisation WHERE Engineer_Name = ? AND Password = ?"; // use PreparedStatement for more security and more easyPreparedStatement pstmt = con.prepareStatement(querySt); pstmt.setString(1, username); // set the 1st quesmark(?) icon value to the user input usernamepstmt.setString(2, password); // set the 2nd quesmark(?) icon value to the user input passwordResultSet rs = pstmt.executeQuery(querySt); if (rs.next()){// Got result mean username and password are correctgotoPage="/FYP/SupplierMainProj.jsp";//Retrieve each column in the row}else{// No result mean incorrect username and passwordgotoPage="/FYP/login.jsp";} // RequestDispatcher dispatcher =getServletContext().getRequestDispatcher(gotoPage);// dispatcher.forward(req, res); } /*For COntractor*/if (Domain.equals("Contractor")){//Issue the SELECT statementString querySt = "SELECT Project_Engineer, Password FROM Supplier WHERE Project_Engineer = ? AND Password = ?"; // use PreparedStatement for more security and more easyPreparedStatement pstmt = con.prepareStatement(querySt); pstmt.setString(1, username); // set the 1st quesmark(?) icon value to the user input usernamepstmt.setString(2, password); // set the 2nd quesmark(?) icon value to the user input passwordResultSet rs = pstmt.executeQuery(querySt); if (rs.next()){// Got result mean username and password are correctgotoPage="/FYP/Sub_main_proj.jsp";}else{// No result mean incorrect username and passwordgotoPage="/FYP/login.jsp";} RequestDispatcher dispatcher =getServletContext().getRequestDispatcher(gotoPage);dispatcher.forward(req, res);} //Close Statement and Connectionstatmt.close();con.close();System.out.println("\nConnection Closed - Operation Successful."); } catch(Exception E){//Print out the Exception ErrorSystem.out.println("Error:" +E );} } }this is my jsp code <HTML> <HEAD> <TITLE> Login </TITLE> <script language="JavaScript" type="text/JavaScript"><!--function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0;}//--></script></HEAD> <BODY> <FORM ACTION="/FYP/servlet/Login" METHOD="doPost"> <CENTER><TABLE BORDER=0> <TR><TD COLSPAN=2><P Align=CENTER>Please enter the Name and<BR> password to login.<P Align=CENTER></TD></TR> <TR><TD><P Align=center> <table width="246" border="1" align="center"> <tr> <td width="75">User name</td> <td width="155"><input name="username" type="text" id="username"></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password"></td> </tr> <tr> <td>Domain</td> <td><select name="Domain" id="Domain" onChange="MM_jumpMenu('parent',this,0)"> <option value="Contractor" selected>Contractor</option> <option value="Subcontractor">Subcontractor</option> </select></td> </tr> </table> <p> </p></TD></TR><TR><TD><P></TD></TR> <TR><TD><P Align=CENTER><INPUT name="Submit" TYPE="submit" VALUE="Login"></TD></TR> </FORM></BODY></HTML>I have tried changing the "doGet" to "doPost" and service but the error merely change from "GET" to "POST". I have also tried removing the /FYP/ but it doesnt work either.Can anyone offer me some assistance? Your assistance is very much appreciated.Thanks.
  5. This is my code:import java.net.URL;import java.sql.*;import java.lang.String;import java.lang.StringBuffer;import java.sql.Connection;public class SQLQuery{ public static void main (String argv[]) { //SQLQueryFormat a = new SQLQueryFormat(); System.out.println("\nEstablishing Connection - Pls Wait... \n"); try { //Connect to the database specified in the URL Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:EG1"); System.out.println("Connection Established.\n"); //Create a SELECT statement object Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); //Issue the SELECT statement String querySt = "SELECT PRT_REF_NO, PRT_DESCR, SPT_IN_STOCK, SPT_CONTROL, SPT_PRICE, SPT_DESCR " + "FROM Parts, SupplierPartLink " + "WHERE PRT_ID = SPT_PRT_ID " + "AND SPT_SUP_ID=1 " + "ORDER BY PRT_REF_NO "; ResultSet res = stmt.executeQuery(querySt); //For each row retrived from the select statement System.out.println("Retriving results for MCK\n"); System.out.println("part Description\t\t Stock\t Control Level\t Price"); System.out.println("---- -----------\t\t -----\t -------------\t -----\n"); while (res.next()) { //Retrieve each column in the row String ref = res.getString("PRT_REF_NO"); //PRT_REF_NO System.out.println(" " + ref); String desc= res.getString(2); //PRT_DESC System.out.println(" " + desc); int stk= res.getInt(3); //SPT_IN_STOCK System.out.println(" " + stk); int ctrl = res.getInt(4); //SPT_CONTROL System.out.println(" " + ctrl); String cost= res.getString(5);//SPT_PRICE System.out.println(" " + cost); } //Close Statement and Connection stmt.close(); con.close(); System.out.println("\nConnection Closed - Operation Successful."); } catch(Exception E) { //Print out the Exception Error System.out.println("Error:" +E ); } } }The prob is that i am unable to display ....System.out.println(" " + ref);....System.out.println(" " + desc); ...System.out.println(" " + stk); ...System.out.println(" " + ctrl); and System.out.println(" " + cost);I have no problem displaying the rest. Can any one offer me some advise on what could have gone wrong?Thanks
×
×
  • Create New...