Database Query terminal (including source code)

Source: Internet
Author: User
Tags netbeans

Note: This program references some examples of sun.

Executable files (including drivers, do not change the folder content ):Download

Executable jar files without drivers:Download(When using the driver, place it in the classpath path)

Source code (netbeans project file ):Download(For learning purposes only, use netbeans)

This software is compiled in pure Java language. Therefore, JRE (Java Runtime Environment HereSelect JRE download), and because of this, it can run on Linux and other operating systems installed with JRE ......

 

Applicable to MySQL, Oracle, and ODBC databases.

The program is very small. Because the database connection often fails to find the driver, the driver added to MySQL and Oracle seems bloated.

1. Enter the user name and password after starting the software.

2. Configure and enter the URL and driver of the database.
2.1 configure the ODBC data source that comes with windows (pass the test in Windows XP): Open the control panel in sequence-> Administrative Tools-> data source (ODBC) (double-click)-> "add"-> select "Microsoft Access Driver (*. MDB) "->" complete "(selected driver)-> enter the data source name (for example, test) --> click "CREATE" in the "Database" column below --> select the database storage directory and define the database name --> "OK "――― -> the system prompts "creation successful"-> select "JDBC: ODBC: test (test is the data source name defined)-> select "Sun. JDBC. ODBC. choose jdbcodbcdriver> connect. (Note that the database name and data source name are two different concepts)

2.2 For MySQL, after the installation is complete, start the database service. Generally, there will be a "test" database. You can directly select JDBC: mysql: // localhost/test and COM. MySQL. JDBC. Driver.

2.3 For Oracle databases, the URL of the database can be configured as "JDBC: oracle: thin: @ xxx. xxx. xxx. XXX: 1521: Database Name ", where" XXX. xxx. xxx. XXX is the IP address and 1521 is the port number. Select oracle. JDBC. Driver. oracledriver as the driver ".

3. Operate the database. You can enter an operation command in the Command window, for example:

Table creation:
Create Table student (
Sno char (5) not null unique,
Sname char (20) unique,
Sgender char (1 ),
Sage int,
Sdept char (15 ),
Smoney double
);

Query:
Select * from student;

Insert (insert a record each time ):
Insert into student values ('20140901', 'sunnyjune', 'M', 23, 'LIFE', 00001 );
Insert into student values ('20140901', 'sunnyjuly', 'F', 18, 'LIFE', 00002 );
Insert into student values ('20140901', 'sunday', 'F', 20, 'LIFE', 00003 );

Change:
Alter table student add stime date;
Update student set sage = sage + 1;
Delete from student where sname = 'sunnyjune ';

Query:
Select * from student;
Select sname, SnO, sdept from student;
Select sname from student where sage <22;
Select max (SAGE) from student;

Delete table:
Drop table student;
Simply put, commands supported by the executeupdate and executequery functions are also related to the corresponding database.

4. Note that only one command can be executed at a time. Click "commite. If no feedback is provided, the operation is successful. If an error or exception occurs, the operation is displayed in the exception output window.

5. You can sort the query results. Double-click the title of the corresponding column to sort the results in ascending order, and press shift to double-click to sort the results in descending order.

Operation interface:

1. Configure connection properties:

 



2. query and output:

 


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.