Skip to content

Commit 449419b

Browse files
committed
numbers
1 parent fc20ebf commit 449419b

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "title-issue-summary",
6+
"metadata": {},
7+
"source": "# Neo4j Simple Connection Test\n\nQuick validation of Neo4j connectivity: network (TCP) and Python driver."
8+
},
9+
{
10+
"cell_type": "markdown",
11+
"id": "config-header",
12+
"metadata": {},
13+
"source": "---\n\n## Configuration\n\nSet your Neo4j Aura credentials below."
14+
},
15+
{
16+
"cell_type": "code",
17+
"execution_count": null,
18+
"id": "config-vars",
19+
"metadata": {},
20+
"outputs": [],
21+
"source": "# =============================================================================\n# CONFIGURATION - Edit these values for your Neo4j instance\n# =============================================================================\n\nNEO4J_URI = \"neo4j+s://123456.databases.neo4j.io\"\nNEO4J_USERNAME = \"neo4j\"\nNEO4J_PASSWORD = \"\"\n\n# Derived values\nNEO4J_HOST = NEO4J_URI.replace(\"neo4j+s://\", \"\")\n\nprint(\"Configuration:\")\nprint(f\" Neo4j URI: {NEO4J_URI}\")\nprint(f\" Neo4j Host: {NEO4J_HOST}\")\nprint(f\" Username: {NEO4J_USERNAME}\")"
22+
},
23+
{
24+
"cell_type": "markdown",
25+
"id": "network-header",
26+
"metadata": {},
27+
"source": "---\n\n## Section 1: Network Connectivity Test (TCP Layer)\n\n**Expected Result**: PASS - Proves network path is open."
28+
},
29+
{
30+
"cell_type": "code",
31+
"execution_count": null,
32+
"id": "network-test",
33+
"metadata": {},
34+
"outputs": [],
35+
"source": "# TCP connectivity test using netcat\nimport subprocess\nimport time\n\nprint(\"=\" * 60)\nprint(\"TEST: Network Connectivity (TCP)\")\nprint(\"=\" * 60)\nprint(f\"\\nTarget: {NEO4J_HOST}:7687 (Bolt protocol port)\")\nprint(\"Testing: Can we reach Neo4j at the network level?\")\n\ntry:\n start_time = time.time()\n result = subprocess.run(\n ['nc', '-zv', NEO4J_HOST, '7687'],\n stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=10\n )\n elapsed = (time.time() - start_time) * 1000\n output = (result.stdout.decode() + result.stderr.decode()).strip()\n\n if result.returncode == 0:\n print(\"\\n\" + \"=\" * 60)\n print(\">>> CONNECTIVITY VERIFIED <<<\")\n print(\"=\" * 60)\n print(f\"\\n[PASS] TCP connection established in {elapsed:.1f}ms\")\n print(f\"\\nConnection Details:\")\n print(f\" - Host: {NEO4J_HOST}\")\n print(f\" - Port: 7687 (Bolt)\")\n print(f\" - TCP Latency: {elapsed:.1f}ms\")\n if output:\n print(f\" - Raw Output: {output}\")\n print(\"\\n\" + \"-\" * 60)\n print(\"RESULT: Network path to Neo4j is OPEN\")\n print(\" Firewall rules allow Bolt protocol traffic\")\n print(\"-\" * 60)\n print(\"\\nStatus: PASS\")\n else:\n print(f\"\\n[FAIL] Cannot reach {NEO4J_HOST}:7687 - check firewall rules\")\n print(f\"Details: {output}\")\n print(\"\\nStatus: FAIL\")\n\nexcept Exception as e:\n print(f\"\\n[FAIL] Error: {e}\")\n print(\"\\nStatus: FAIL\")"
36+
},
37+
{
38+
"cell_type": "markdown",
39+
"id": "python-driver-header",
40+
"metadata": {},
41+
"source": "---\n\n## Section 2: Neo4j Python Driver Test\n\n**Expected Result**: PASS - Proves credentials work and Neo4j is accessible."
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": null,
46+
"id": "python-driver-test",
47+
"metadata": {},
48+
"outputs": [],
49+
"source": "# Test Neo4j Python driver connectivity\nimport time\n\nprint(\"=\" * 60)\nprint(\"TEST: Neo4j Python Driver\")\nprint(\"=\" * 60)\nprint(f\"\\nTarget: {NEO4J_URI}\")\nprint(\"Testing: Can we authenticate and execute queries via Bolt protocol?\")\n\nfrom neo4j import GraphDatabase\n\ntry:\n start_time = time.time()\n driver = GraphDatabase.driver(NEO4J_URI, auth=(NEO4J_USERNAME, NEO4J_PASSWORD))\n \n # Verify connectivity\n driver.verify_connectivity()\n connect_time = (time.time() - start_time) * 1000\n \n print(\"\\n\" + \"=\" * 60)\n print(\">>> AUTHENTICATION SUCCESSFUL <<<\")\n print(\"=\" * 60)\n print(f\"\\n[PASS] Driver connected and authenticated in {connect_time:.1f}ms\")\n \n # Test simple query\n with driver.session() as session:\n query_start = time.time()\n result = session.run(\"RETURN 1 AS test\")\n record = result.single()\n query_time = (time.time() - query_start) * 1000\n print(f\"[PASS] Query executed: RETURN 1 = {record['test']} ({query_time:.1f}ms)\")\n \n # Get Neo4j version\n result = session.run(\"CALL dbms.components() YIELD name, versions RETURN name, versions\")\n neo4j_info = []\n for record in result:\n neo4j_info.append(f\"{record['name']} {record['versions']}\")\n \n total_time = (time.time() - start_time) * 1000\n driver.close()\n \n print(f\"\\nConnection Details:\")\n print(f\" - URI: {NEO4J_URI}\")\n print(f\" - User: {NEO4J_USERNAME}\")\n print(f\" - Neo4j Server: {', '.join(neo4j_info)}\")\n print(f\" - Connection Time: {connect_time:.1f}ms\")\n print(f\" - Total Test Time: {total_time:.1f}ms\")\n \n print(\"\\n\" + \"-\" * 60)\n print(\"RESULT: Neo4j Python Driver connection WORKING\")\n print(\" Credentials valid, Bolt protocol functional\")\n print(\"-\" * 60)\n print(\"\\nStatus: PASS\")\n \nexcept Exception as e:\n print(f\"\\n[FAIL] Connection failed: {e}\")\n print(\"\\nStatus: FAIL\")"
50+
}
51+
],
52+
"metadata": {
53+
"kernelspec": {
54+
"display_name": "Python 3",
55+
"language": "python",
56+
"name": "python3"
57+
},
58+
"language_info": {
59+
"name": "python",
60+
"version": "3.11.0"
61+
}
62+
},
63+
"nbformat": 4,
64+
"nbformat_minor": 5
65+
}

neo4j-uc-federation-lab/simple_jdbc_connection.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"cell_type": "markdown",
55
"id": "title",
66
"metadata": {},
7-
"source": "# Simple JDBC Connection Test\n\nA minimal notebook to verify the Neo4j JDBC driver and Unity Catalog JDBC connection are working.\n\n**Before running this notebook**, create a test node in your Neo4j database:\n\n```cypher\nMERGE (n:JdbcTest {id: 1})\nSET n.message = 'hello from Neo4j',\n n.created = datetime()\nRETURN n\n```\n\n**Prerequisites**:\n- Run `setup.sh` to configure Databricks secrets\n- Upload the Neo4j Unity Catalog Connector JAR to a UC Volume\n- Install the connector JAR as a cluster library"
7+
"source": "# Simple JDBC Connection Test\n\nA minimal notebook to verify the Neo4j JDBC driver and Unity Catalog JDBC connection are working.\n\n**Before running this notebook**, create a test node in your Neo4j database:\n\n```cypher\nMERGE (n:JdbcTest {id: 1})\nSET n.message = 'hello from Neo4j',\n n.created = datetime()\nRETURN n\n```\n\n**Prerequisites**:\n- Upload the Neo4j Unity Catalog Connector JAR to a UC Volume\n- Install the connector JAR as a cluster library\n- Update the configuration values in the next cell"
88
},
99
{
1010
"cell_type": "code",
1111
"execution_count": null,
1212
"id": "config",
1313
"metadata": {},
1414
"outputs": [],
15-
"source": "# =============================================================================\n# CONFIGURATION - Loaded from Databricks Secrets\n# =============================================================================\nSCOPE_NAME = \"neo4j-uc-creds\"\n\nNEO4J_HOST = dbutils.secrets.get(SCOPE_NAME, \"host\")\nNEO4J_USER = dbutils.secrets.get(SCOPE_NAME, \"user\")\nNEO4J_PASSWORD = dbutils.secrets.get(SCOPE_NAME, \"password\")\n\ntry:\n NEO4J_DATABASE = dbutils.secrets.get(SCOPE_NAME, \"database\")\nexcept:\n NEO4J_DATABASE = \"neo4j\"\n\nJDBC_JAR_PATH = dbutils.secrets.get(SCOPE_NAME, \"jdbc_jar_path\")\nUC_CONNECTION_NAME = dbutils.secrets.get(SCOPE_NAME, \"connection_name\")\n\nJAVA_DEPENDENCIES = f'[\"{JDBC_JAR_PATH}\"]'\nNEO4J_JDBC_URL = f\"jdbc:neo4j+s://{NEO4J_HOST}:7687/{NEO4J_DATABASE}\"\nNEO4J_JDBC_URL_SQL = f\"{NEO4J_JDBC_URL}?enableSQLTranslation=true\"\n\nprint(f\"Neo4j Host: {NEO4J_HOST}\")\nprint(f\"JDBC URL: {NEO4J_JDBC_URL_SQL}\")\nprint(f\"Connection Name: {UC_CONNECTION_NAME}\")\nprint(f\"JDBC JAR Path: {JDBC_JAR_PATH}\")"
15+
"source": "# =============================================================================\n# CONFIGURATION - Update these values for your environment\n# =============================================================================\nNEO4J_HOST = \"<your-neo4j-host>\" # e.g. \"abc123.databases.neo4j.io\"\nNEO4J_USER = \"<your-neo4j-user>\" # e.g. \"neo4j\"\nNEO4J_PASSWORD = \"<your-neo4j-password>\"\nNEO4J_DATABASE = \"neo4j\" # default database\n\n# Path to the connector JAR in a UC Volume\nJDBC_JAR_PATH = \"/Volumes/<catalog>/<schema>/<volume>/neo4j-unity-catalog-connector.jar\"\n\n# Name for the Unity Catalog connection\nUC_CONNECTION_NAME = \"<catalog>.<schema>.neo4j_jdbc\"\n\n# Derived values (no need to edit)\nJAVA_DEPENDENCIES = f'[\"{JDBC_JAR_PATH}\"]'\nNEO4J_JDBC_URL = f\"jdbc:neo4j+s://{NEO4J_HOST}:7687/{NEO4J_DATABASE}\"\nNEO4J_JDBC_URL_SQL = f\"{NEO4J_JDBC_URL}?enableSQLTranslation=true\"\n\nprint(f\"Neo4j Host: {NEO4J_HOST}\")\nprint(f\"JDBC URL: {NEO4J_JDBC_URL_SQL}\")\nprint(f\"Connection Name: {UC_CONNECTION_NAME}\")\nprint(f\"JDBC JAR Path: {JDBC_JAR_PATH}\")"
1616
},
1717
{
1818
"cell_type": "markdown",

0 commit comments

Comments
 (0)