搜索插件、代码仓与 APP 分类

插件详情v2.0.0

sql_conn

使用 JDBC 和安全连接池的通用生产就绪 Flutter SQL 连接器。

Android
近 30 天下载
137
喜欢数
52
Pub 分数
150

安装插件

flutter pub add sql_conn

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

sql_conn 是一个面向生产环境的 Flutter SQL 连接器,专为使用 JDBC 的安全高效数据库交互而设计。它提供连接池以优化性能,并在高负载环境中确保可靠性。该库从安全性出发构建,支持加密通信和跨 Android 平台的连接池。适用于需要强大后端数据库集成且延迟极低的应用程序。该包简化了 SQL 操作,同时保持可扩展性和线程安全性。

适合场景

  • 将Flutter应用连接到远程数据库
  • 处理高流量数据库查询
  • 在生产环境中保护数据库连接
  • 启用持久连接池
  • 与现有 JDBC 兼容数据库集成
  • 支持仅 Android 数据库部署

主要特点

  • 基于 JDBC 的连接
  • 安全连接池
  • 生产级稳定性
  • Android 平台支持
  • 加密数据传输
  • 线程安全操作

适合对象

  • 企业级 Flutter 应用
  • 高流量的数据库支持的应用程序
  • 需要安全数据库访问的应用程序
  • 使用 JDBC 兼容数据库的开发人员
  • 注重连接效率的团队
  • 面向Android的数据库集成

使用建议

  • 仅限 Android 平台
  • 需要 JDBC 驱动程序兼容性
  • 需要正确的SSL配置
  • 可能需要为复杂架构进行额外设置
  • 不适用于 iOS 或网页
  • 依赖外部JDBC基础设施

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

sql_conn

sql_conn is a production-ready Flutter plugin that allows Android applications to connect directly to SQL SERVER databases using JDBC.

It provides a clean, type-safe, null-safe Dart API powered by Pigeon, and a high-performance Android backend.

This plugin is designed for LAN / internal network / enterprise / industrial use-cases where direct database connectivity from a mobile device is required.


✨ Features

  • Android-only direct SQL connectivity
  • Database support:
    • Microsoft SQL Server
  • Prepared statements (parameterized queries)
  • Stored procedure execution
  • SQL script / batch execution
  • Fully null-safe Dart API
  • Type-safe Flutter ↔ Android bridge using Pigeon

📱 Platform Support

Platform Support
Android ✅ Yes
iOS 🚧 Under construction
Web 💭 Planning
Windows 🚫 No
MacOs 🚫 No

Direct database connections from mobile apps should only be used in trusted or internal networks.


🚀 Installation

Add to pubspec.yaml:

dependencies:
  sql_conn: ^2.0.0

⚙️ Basic Usage

Connect to a database
await SqlConn.connect(
  connectionId: "mainDB",
  host: "192.168.1.10",
  port: 1433,
  database: "MyDatabase",
  username: "admin",
  password: "Password@123",
);
Read data
final rows = await SqlConn.read(
  "mainDB",
  "SELECT * FROM users WHERE role = ?",
  params: ["admin"],
);

print(rows);
Write / Update / Delete
final count = await SqlConn.write(
  "mainDB",
  "UPDATE users SET active = ? WHERE id = ?",
  params: [true, 101],
);

print("Rows affected: $count");
Call Stored Procedure
final result = await SqlConn.callProcedure(
  "mainDB",
  "sp_generate_report",
  params: [2026, "JAN"],
);
Execute SQL Script
await SqlConn.executeScript(
  "mainDB",
  """
  CREATE TABLE logs(id INT, message VARCHAR(255));
  CREATE INDEX idx_logs ON logs(id);
  """,
);
Disconnect
await SqlConn.disconnect("mainDB");
🧩 Multiple Connections
await SqlConn.connect(connectionId: "db1", dbType: DatabaseType.sqlServer, ...);
await SqlConn.connect(connectionId: "db2", dbType: DatabaseType.postgres, ...);

final a = await SqlConn.read("db1", "SELECT * FROM table1");
final b = await SqlConn.read("db2", "SELECT * FROM table2");
🔧 Custom JDBC URL
await SqlConn.connect(
  connectionId: "legacy",
  host: "",
  port: 0,
  database: "",
  username: "sysdba",
  password: "masterkey",
  customJdbcUrl: "jdbc:firebirdsql://192.168.1.9/employee",
);

🧠 State Management

sql_conn is a stateless service API. You can integrate it with any state manager:

  • Provider
  • Riverpod
  • Bloc
  • GetX
  • Service Locators
  • Connection lifecycle is fully controlled by your app.

⚡ Performance

  • Prepared statement reuse
  • Non-blocking platform channel
  • Minimal memory overhead

🔐 Security

  • Prepared statements prevent SQL injection
  • No credential logging

所属分类

源码仓库

使用此插件的项目

暂无相关数据。