Reputation: 51
I tried creating a new class with a method that set the connection strings to public static variables via a properties file using the input filestream.
then the idea was that in: DriverManager.getConnection(<the global variable containing the connection string>)
However I'm presented with a java.sql.SQLException: No suitable driver found for "jdbc:mysql://localhost:3306/tr" error.
I find this really strange because the variable doesnt work, but when i System.output.println(variable)
it, and copy the output in console into the DriverManager.getConnection(>Paste here<)
it works fine.
Could someone possibly answer the question and explain to me why this happens?
Thanks.
Upvotes: 0
Views: 415
Reputation: 169
you should use property value after using calling trim so that extra space can be removed.....
Upvotes: 0
Reputation: 61148
In a Java properties file, the key is before an =
and the value is after.
Everything after the =
is the value.
dburl=jdbc:mysql://localhost:3306/tr
i.e. No quotes.
Upvotes: 2