Home Database Mysql Tutorial java查询访问的access数据库

java查询访问的access数据库

Jun 07, 2016 pm 03:49 PM
access java database Inquire access Enter

欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入 java查询访问access数据库 package chapter10; import java.sql.*; public class AccessData { public AccessData() { } public static void main(String[] args) { new AccessData(); Strin

欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入

    java查询访问access数据库

    package chapter10;

    import java.sql.*;

    public class AccessData {

    public AccessData()

    {

    }

    public static void main(String[] args) {

    new AccessData();

    String url=“jdbc:odbc:mydbaccess”;

    String query,name,mark;

    Connection conn=null;

    Statement statement=null;

    ResultSet resultSet=null;

    try{

    Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

    conn=DriverManager.getConnection(url);

    statement=conn.createStatement();

    query=“select * from student”;

    resultSet=statement.executeQuery(query);

    while(resultSet.next())

    {

    name=resultSet.getString(“name”);

    mark=resultSet.getString(“mark”);

    System.out.print(“姓名: ”+name);

    System.out.println(“ 分数: ”+mark);

    }

    }

    catch(SQLException e)

    {

    e.printStackTrace();

    }

    catch(Exception e)

    {

    e.printStackTrace();

    }

    finally{

    try{

    if(resultSet!=null) resultSet.close();

    if(statement!=null) statement.close();

    if(conn!=null) conn.close();

    }

    catch(SQLException e)

    {

    e.printStackTrace();

    }

    }

    }

    }

    显示结果:

    姓名: 李明 分数: 81

    姓名: 张三 分数: 85

    姓名: 李四 分数: 90

    姓名: 王五 分数: 75

    姓名: 陈六 分数: 68

    姓名: 赵八 分数: 90

    姓名: 黄九 分数: 10

    姓名: 孙红 分数: 82

java查询访问的access数据库

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
Oracle's Role in the Business World Oracle's Role in the Business World Apr 23, 2025 am 12:01 AM

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

What are the plugins for wordpress blocking ip What are the plugins for wordpress blocking ip Apr 20, 2025 am 08:27 AM

WordPress IP blocking plugin selection is crucial. The following types can be considered: based on .htaccess: efficient, but complex operation; database operation: flexible, but low efficiency; firewall: high security performance, but complex configuration; self-written: highest control, but requires more technical level.

Redis: Understanding Its Architecture and Purpose Redis: Understanding Its Architecture and Purpose Apr 26, 2025 am 12:11 AM

Redis is a memory data structure storage system, mainly used as a database, cache and message broker. Its core features include single-threaded model, I/O multiplexing, persistence mechanism, replication and clustering functions. Redis is commonly used in practical applications for caching, session storage, and message queues. It can significantly improve its performance by selecting the right data structure, using pipelines and transactions, and monitoring and tuning.

How to understand DMA operations in C? How to understand DMA operations in C? Apr 28, 2025 pm 10:09 PM

DMA in C refers to DirectMemoryAccess, a direct memory access technology, allowing hardware devices to directly transmit data to memory without CPU intervention. 1) DMA operation is highly dependent on hardware devices and drivers, and the implementation method varies from system to system. 2) Direct access to memory may bring security risks, and the correctness and security of the code must be ensured. 3) DMA can improve performance, but improper use may lead to degradation of system performance. Through practice and learning, we can master the skills of using DMA and maximize its effectiveness in scenarios such as high-speed data transmission and real-time signal processing.

How to parse next-auth generated JWT token in Java and get information in it? How to parse next-auth generated JWT token in Java and get information in it? Apr 19, 2025 pm 08:21 PM

In processing next-auth generated JWT...

Composer: Aiding PHP Development Through AI Composer: Aiding PHP Development Through AI Apr 29, 2025 am 12:27 AM

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

What does 'platform independence' mean in the context of Java? What does 'platform independence' mean in the context of Java? Apr 23, 2025 am 12:05 AM

Java's platform independence means that the code written can run on any platform with JVM installed without modification. 1) Java source code is compiled into bytecode, 2) Bytecode is interpreted and executed by the JVM, 3) The JVM provides memory management and garbage collection functions to ensure that the program runs on different operating systems.

MongoDB's Future: The State of the Database MongoDB's Future: The State of the Database Apr 25, 2025 am 12:21 AM

MongoDB's future is full of possibilities: 1. The development of cloud-native databases, 2. The fields of artificial intelligence and big data are focused, 3. The improvement of security and compliance. MongoDB continues to advance and make breakthroughs in technological innovation, market position and future development direction.

See all articles