开发者

Java Servlet MySQL Unknown Table Names

开发者 https://www.devze.com 2023-01-31 13:02 出处:网络
I ha开发者_开发技巧ve a Java servlet that connects to a MySQL database. And it is possible to create new tables under runtime, which means I do not know what their names are.

I ha开发者_开发技巧ve a Java servlet that connects to a MySQL database. And it is possible to create new tables under runtime, which means I do not know what their names are.

So here is the problem; I want to be able to find a value in the unknown table, and compare it to another in a table I have the name of.. I'm not sure where to go, or if this is even possible.

SHOW TABLES IN database_name;

Returns all the tables I want to use.

Appreciate any help.


You can use the getTables() function on a DatabaseMetaData object to get the names of the tables in the database. It takes a tableNamePattern argument.


You need to know something about the table. If you don't know the name, you need to know something about it to determine what its name is. This determines what you must do to lookup the name. i.e. you need to be more specific about what you know about the table.


Sounds like you're trying to re-implement database CRUD from scratch. Most good web frameworks already do this quite well. Try learning Grails.

0

精彩评论

暂无评论...
验证码 换一张
取 消