I have a class wich connects to MySQL database. I want to make it more universal. I'm not sure in myself. My class can connect any server if you specify the database name.
String url="jdbc:mysql://"+host+":"+port+"/"+dbname;
Can someone tell me, how can I connect without the specifying the database name(to use create database command for example)? Is it correct to use:
String url="jdbc:mysql://"+host+":"+port
or it uses other syntax? Thanks in advance!
Yes, you can use String url="jdbc:mysql://"+host+":"+port
but during the execution of query you need to specify the database
name as
select * from dbname.table
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With