I'm trying to make a Java application that can access a MySQL database hosted there and send SELECT
and UPDATE
statements to a specific table.
My current connection code is looking like this:
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setUser("username"); -- line 1
dataSource.setPassword("password"); -- line 2
dataSource.setURL("db url"); -- line 3
However the bottom three lines are throwing these errors in Eclipse:
Line 1 and 2:
- Syntax error on token ";", @ expected
- Syntax error on token ".", @ expected after
Line 3:
- Syntax error, insert "SimpleName" to complete
QualifiedName
- Syntax error, insert ")" to complete MethodDeclaration
- Syntax error, insert "Identifier (" to complete
MethodHeaderName
I looked into the source code for MysqlDataSource
, and setUser
is definitely public (as well as setPassword
and setServerName
). I have no idea why it's causing an issue.