Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Fehlermeldung beim Versuch, HTML-Dropdown mit MySQL-Daten in Java zu füllen?

Ändern Sie Ihre HTML-Seite in jsp und folgen Sie diesem Code:

<%@page import="java.sql.*"%>
<html>
<form name="form" method="post" >
<b>Select a country:</b> </td>
<select name="sel"><option value=""><---Select---></option>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
String connectionURL = "jdbc:mysql://localhost:3306/test";
Connection connection= DriverManager.getConnection('jdbc:mysql://192.168.1.104:3306/networkmonitoring','mohsin','123456');");
PreparedStatement psmnt = connection.prepareStatement("select objecttype_name from network_objecttype ");
ResultSet results = psmnt.executeQuery();
while(results.next()){
String name = results.getString('objecttype_name');
String id = results.getString('objecttype_name');
%><option value="<%= name %>"><%=name%></option>
<%} results.close(); psmnt.close(); %>
</select><br>
</form>