Accessing Hyphenated Column Names in MySQL from Java
Despite searching extensively, you couldn't find a solution to accessing MySQL column names that contain hyphens. When attempting to use these names from Java code, the names break at the hyphen, causing them to become unrecognized. You've unsuccessfully tried substituting underscores in your code to resolve the issue.
To resolve this, you can enclose the column names within '`' (backticks) when referencing them in your Java code. This will allow you to access the columns without encountering the hyphenation error.
For example, if you have a column named 'air_port' in your MySQL database, you can access it in your Java code using:
ResultSet resultSet = statement.executeQuery("SELECT * FROM `air_port`");
The above is the detailed content of How Can I Access Hyphenated MySQL Column Names from Java?. For more information, please follow other related articles on the PHP Chinese website!