Simple test database plus applet

xiaoxiao2021-03-05  48

Create a database name Database, username, and account user and pass, then establish a data source in the Control Panel, for clear, data source names for Database, username, and account as described above, then write code as follows, simply test The program and database connection.

Import java.sql. *;

Public class test {public static void main (string ") {string URL =" JDBC: ODBC: Database "; try {class.forname (" sun.jdbc.odbc.jdbcodbcdriver); system.out.println (" "); connection conn = drivermanager.getConnection (URL," User "," pass "); system.out.println (" Success Connect to Database ");} catch (Exception E) {E.PrintStackTrace ();} }

Note that when you build a data source, choose the SQL Server verification using the user to enter the login ID and password.

转载请注明原文地址:https://www.9cbs.com/read-32935.html

New Post(0)