Java, XML and Database Programming Practice (1)

zhaozj2021-02-16  35

Java, XML and Database Programming Practice (1)

Author: sirix Email: nevinguo@163.com

When you start learning XML and database programming, everyone will start with a lot of documents and materials. The author is working in the work, and it is necessary to use it. Its feature is very simple, you have to use the Java language, import some data into the SQL database from the Access database.

demand:

Original Access database table structure:

Table: Production

Product model string type ......... Product number

Part map number string ......... Part number

Timber string .......................................

SQL data table structure:

Project product table

ID INT logo

Number ... varchar64 number

Product Part Table

ID INT logo

PID INT product identification number (associated with ID in the Project table)

Number ... varchar64 number

Production tool table corresponding to ComponentType and Parts

ID INT logo

AID INT Part Identification (association with the IDUCT table)

Number ... varchar64 number

The original numbers are required to be placed in the SQL three tables, and associated with the ID.

Considering that database connections may change, decide to use XML to configure data connections. The DBS.XML file content is as follows:

sun.jdbc.odbc.jdbcodbcdriver

JDBC: ODBC: ASRS

"

"

com.microsoft.jdbc.sqlserver.sqlserverdriver

JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = VXMS

vxms

Vxms

File Connpara.java, indicating database connection parameters represented by a class form.

Public Class Connpara

{

String dbclass = NULL;

String Url = NULL;

String username = null;

String password = NULL;

Public connpara () {}

Public Connpara (String Pdbclass, String Purl, String Puser, String PPassword)

{

dbclass = pdbclass;

URL = PURL;

UserName = PUSERNAME;

Password = ppassword;}

Public string getdbclass () {return dbclass;}

Public string geturl () {return url;}

Public string getUsername () {return username;}

Public string getpassword () {return password;}

Public void setdbclass (string str) {dbclass = Str;}

Public void seturl (string str) {url = Str;}

Public void setusername (string str) {username = Str;}

Public void setpassword (string str) {password = Str;}

}

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

New Post(0)