Advertisement
Guest User

Untitled

a guest
Feb 18th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. <select>
  2. <%
  3. Connection con=null;
  4. ResultSet rs=null;
  5.  
  6. try
  7. {
  8. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  9. con=DriverManager.getConnection("jdbc:odbc:db","root","root");
  10. HttpSession ss=request.getSession();
  11. String uid=(String)ss.getAttribute("id");
  12. PreparedStatement pst=con.prepareStatement("select name from emp where uid=?");
  13. pst.setString(1,uid);
  14. rs=pst.executeQuery();
  15. while(rs.next())
  16. {
  17. out.print(rs.getString("name"));
  18. %>
  19. </select>
  20. <%
  21. }
  22. }catch(Exception e)
  23. { out.print(e);
  24. }
  25. %>
  26.  
  27. <select>
  28. <%
  29. Connection con=null;
  30. ResultSet rs=null;
  31.  
  32. try
  33. {
  34. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  35. con=DriverManager.getConnection("jdbc:odbc:db","root","root");
  36. HttpSession ss=request.getSession();
  37. String uid=(String)ss.getAttribute("id");
  38. PreparedStatement pst=con.prepareStatement("select name from emp where uid=?");
  39. pst.setString(1,uid);
  40. rs=pst.executeQuery();
  41. while(rs.next())
  42. {
  43. String name = rs.getString("name");
  44. %>
  45. <option value="<%=name%>"><%=name%></option>
  46. <%
  47. }
  48. }catch(Exception e)
  49. { out.print(e);
  50. }
  51. %>
  52. </select>
  53.  
  54. arabaid int,
  55. arabaadi varchar(100),
  56. constraint ck_arabaid primary key (arabaid)
  57.  
  58. modelid int,
  59. modeladi varchar(100),
  60. arabaid int,
  61. constraint ck_modelid primary key (modelid),
  62. constraint ck_arabaid foreign key (arabaid) references araba(arabaid)
  63.  
  64. <select name="araba" id="araba" onchange="this.form.submit();">
  65. <option value="0">Kategori Seç</option>
  66. <%@ page import ="java.sql.*" %>
  67. <%@ page import ="javax.sql.*" %>
  68. <%
  69. try
  70. {
  71. String Query = "Select * From araba";
  72. Class.forName("org.postgresql.Driver").newInstance();
  73. java.sql.Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Proje", "postgres", "155");
  74. Statement stm = conn.createStatement();
  75. ResultSet rs = stm.executeQuery(Query);
  76. while(rs.next())
  77. {
  78. %>
  79. <option value="<%=rs.getInt("arabaid")%>"
  80.  
  81. <%
  82. if(request.getParameter("araba")!=null)
  83. {
  84. if(rs.getInt("arabaid") == Integer.parseInt(request.getParameter("araba")))
  85. {
  86. out.print("selected");
  87. }
  88. }
  89. %>
  90.  
  91. ><%=rs.getString("arabaadi")%></option>
  92. <%
  93. }
  94. }
  95. catch(Exception ex)
  96. {
  97. ex.printStackTrace();
  98. }
  99. %>
  100. </select>
  101.  
  102. <select>
  103. <option value="0">Model Seç</option>
  104. <%@ page import ="java.sql.*" %>
  105. <%@ page import ="javax.sql.*" %>
  106. <%
  107. Connection con=null;
  108. ResultSet rs=null;
  109.  
  110. try
  111. {
  112. Class.forName("org.postgresql.Driver");
  113. con=DriverManager.getConnection("jdbc:postgresql://localhost:5432/Proje", "postgres", "155");
  114. HttpSession ss=request.getSession();
  115. String aid=(String)ss.getAttribute("arabaid");
  116. PreparedStatement pst=con.prepareStatement("select modeladi from model where aid=?");
  117. pst.setString(1,aid);
  118. rs=pst.executeQuery();
  119. while(rs.next())
  120. {
  121. String name = rs.getString("modeladi");
  122. %>
  123. <option value="<%=name%>"><%=name%></option>
  124. <%
  125. }
  126. }catch(Exception e)
  127. { out.print(e);
  128. }
  129. %>
  130. </select>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement