Reputation: 6543
I'm pretty new with Java (though I'm experienced with C#). Anyway I've Googled a lot in the last few hours and I can't understand something. I'm hoping you can help me with some guidance.
I'd like to use Eclipse with SQL Server and I have no idea how am I doing that. I've seen some plugin called SQLExplorer but I just can't figure what are the steps to integrate with that.
Regarding:
Thank you all.
Upvotes: 3
Views: 22726
Reputation: 81724
Java and databases go together like bread and butter, but the language is just different enough that you might have issues breaking in. There are a number of different levels at which things can be integrated: the traditional query/result API is called JDBC, and all you need to work with any database from Java code is the appropriate JDBC driver. Here is the official one from Microsoft for SQL Server, and here is a tutorial about using the JDBC API.
Above that, there are object-relational mapping tools like Hibernate which let you persist Java objects directly onto your database. Hibernate automates a lot of the mapping and lets you work at a high level. Hibernate is an enormous subject; start here.
What SQLExplorer, and tools like it, let you do is browse around in a database, exploring the tables and the data in them. It's not something you use with code, but rather interactively to examine the data you're working with.
Here is a JDBC "Hello World," assuming the default database on the local machine, a table named some_table_name
has a character-valued column in the first position:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost";
Connection con = DriverManager.getConnection(connectionUrl);
Statement s = con.createStatement();
ResultSet r = s.executeQuery("SELECT * FROM some_table_name");
while (r.next()) {
System.out.println(r.getString(1));
}
Upvotes: 6