String projectId = "your-project-id"; String instanceId = "your-instance-id"; String databaseId = "your-database-id"; String jdbcUrl = String.format("jdbc:cloudspanner:/projects/%s/instances/%s/databases/%s", projectId, instanceId, databaseId); Properties properties = new Properties(); properties.setProperty("user", "your-username"); properties.setProperty("password", "your-password"); Connection connection = DriverManager.getConnection(jdbcUrl, properties); Statement statement = connection.createStatement(); ResultSet resultSet = statement.executeQuery("SELECT * FROM your_table"); while (resultSet.next()) { String column1Value = resultSet.getString("column1"); int column2Value = resultSet.getInt("column2"); } resultSet.close(); statement.close(); try { } catch (SQLException e) { }


上一篇:
下一篇:
切换中文