JDBC connection without database definition
java, jdbc, mysql
Solution
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
Problem
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!