How to Connect to ODB Java
Java includes database ODB drivers to connect to a database file created by manufacturers such as MySQL, Microsoft and Oracle. You must use the driver connection to "talk" to the database. The driver translates the queries executed on the database file or server and allows the Java language to interpret the results and display them on your desktop form for users to review.
Instructions
-
-
1
Open your Java programming software and the desktop project you want to edit. Double-click the data connections source code file to load it in the Java editor.
-
2
Add the connection drivers for the SQL language. You need these drivers to query the server. Add the following code to the top of your file:
import java.sql.Connection;
-
-
3
Create the connection string variables. The following code sets up the strings you use with the connection libraries:
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:northwind";
String username = user"";
String password = "pass";Replace the "user" and "pass" values with your username and password.
-
4
Create the connection object:
Connection connect = new Connection(url, username, password);
-
1