2020-04-15 13:56:49 +00:00
---
machine_translated: true
2020-05-15 04:34:54 +00:00
machine_translated_rev: 72537a2d527c63c07aa5d2361a8829f3895cf2bd
2020-04-15 13:56:49 +00:00
toc_priority: 34
toc_title: JDBC
---
# JDBC {#table-engine-jdbc}
ClickHouse üzerinden harici veritabanları na bağlanmak için izin verir [JDBC ](https://en.wikipedia.org/wiki/Java_Database_Connectivity ).
JDBC bağlantı sı nı uygulamak için ClickHouse ayrı programı kullanı r [clickhouse-JDBC-köprü ](https://github.com/alex-krash/clickhouse-jdbc-bridge ) bu bir daemon olarak çalı şmalı dı r.
2020-04-30 18:19:18 +00:00
Bu motor destekler [Nullable ](../../../sql-reference/data-types/nullable.md ) veri türü.
2020-04-15 13:56:49 +00:00
## Tablo oluşturma {#creating-a-table}
``` sql
CREATE TABLE [IF NOT EXISTS] [db.]table_name
(
columns list...
)
ENGINE = JDBC(dbms_uri, external_database, external_table)
```
**Motor Parametreleri**
- `dbms_uri` — URI of an external DBMS.
Biçimli: `jdbc:<driver_name>://<host_name>:<port>/?user=<username>&password=<password>` .
MySQL örneği: `jdbc:mysql://localhost:3306/?user=root&password=root` .
- `external_database` — Database in an external DBMS.
- `external_table` — Name of the table in `external_database` .
## Kullanı m Örneği {#usage-example}
Doğrudan konsol istemcisine bağlanarak MySQL sunucusunda bir tablo oluşturma:
``` text
mysql> CREATE TABLE `test` .`test` (
-> `int_id` INT NOT NULL AUTO_INCREMENT,
-> `int_nullable` INT NULL DEFAULT NULL,
-> `float` FLOAT NOT NULL,
-> `float_nullable` FLOAT NULL DEFAULT NULL,
-> PRIMARY KEY (`int_id`));
Query OK, 0 rows affected (0,09 sec)
mysql> insert into test (`int_id`, `float` ) VALUES (1,2);
Query OK, 1 row affected (0,00 sec)
mysql> select * from test;
+------+----------+-----+----------+
| int_id | int_nullable | float | float_nullable |
+------+----------+-----+----------+
| 1 | NULL | 2 | NULL |
+------+----------+-----+----------+
1 row in set (0,00 sec)
```
2020-05-15 04:34:54 +00:00
ClickHouse Server'da bir tablo oluşturma ve ondan veri seçme:
2020-04-15 13:56:49 +00:00
``` sql
CREATE TABLE jdbc_table
(
`int_id` Int32,
`int_nullable` Nullable(Int32),
`float` Float32,
`float_nullable` Nullable(Float32)
)
ENGINE JDBC('jdbc:mysql://localhost:3306/?user=root& password=root', 'test', 'test')
```
``` sql
SELECT *
FROM jdbc_table
```
``` text
┌─int_id─┬─int_nullable─┬─float─┬─float_nullable─┐
│ 1 │ ᴺᵁᴸᴸ │ 2 │ ᴺᵁᴸᴸ │
└────────┴──────────────┴───────┴────────────────┘
```
## Ayrı ca Bakı nı z {#see-also}
2020-04-30 18:19:18 +00:00
- [JDBC tablo işlevi ](../../../sql-reference/table-functions/jdbc.md ).
2020-04-15 13:56:49 +00:00
[Orijinal makale ](https://clickhouse.tech/docs/en/operations/table_engines/jdbc/ ) <!--hide-->