import java.sql.*; public class DatabricksJDBCExample { public static void main(String[] args) { String url = "jdbc:databricks://hostname:port/database"; String user = "your_username"; String password = "your_password"; try { // Establish a connection Connection connection = DriverManager.getConnection(url, user, password); // Create a statement Statement statement = connection.createStatement(); // Execute a SQL query ResultSet resultSet = statement.executeQuery("SELECT * FROM table"); // Process the query results while (resultSet.next()) { // Process each row String column1Value = resultSet.getString("column1"); int column2Value = resultSet.getInt("column2"); System.out.println(column1Value + " " + column2Value); } // Close the connection connection.close(); } catch (SQLException e) { e.printStackTrace(); } } }


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