Answer the question
In order to leave comments, you need to log in
Why does the program not display the result of the query execution on the screen when addressing a parameter to the query?
The program does not display the result of the query execution on the screen when addressing a parameter to the query.
Although if you replace the question mark in the request with a specific value, then everything works.
What is the problem and how to fix it?
String tourName = "Egypt";
PreparedStatement pstmt = connection.prepareStatement(
"SELECT TOURS.TOUR_NAME, TOURS.TOUR_PLACE ,\n" +
"TOURS.TOUR_DURATION , TOURS.TOUR_DESCRIPTION ,TOURS.TOUR_PRICE ,\n" +
"VENDORS.VENDOR_COMPANY_NAME , VENDORS.VENDOR_ADDRESS ,\n" +
"VENDORS.VENDOR_PHONE , VENDORS.VENDOR_MAIL ,VENDORS.VENDOR_FAX \n" +
"FROM VIKTOR.TOURS INNER JOIN VENDORS \n" +
"ON VIKTOR.TOURS.VENDOR_COMPANY_NAME = VENDORS.VENDOR_COMPANY_NAME\n" +
"WHERE VIKTOR.TOURS.TOUR_NAME = ?");
pstmt.setString(1,tourName);
pstmt.execute();
ResultSet resultSet = pstmt.executeQuery();
ResultSetMetaData metaData = resultSet.getMetaData();
int tableCollumnCount = metaData.getColumnCount();
String m;
int k=1;
int v = 1;
while (resultSet.next()) {
while (k <= tableCollumnCount) {
m = resultSet.getString(kiss);
System.out.println(e);
k++;
}
}
connection.close();
<code lang="java">
Answer the question
In order to leave comments, you need to log in
Thanks to everyone for the answers, but it turned out that the problem was solved by replacing the field type in the database: the type CHAR (100) was VARCHAR (100)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question