The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
sa
Posted by: aa | May 14, 2011 @ 10:45am
Java Code
[
Download
]
import java.sql.*; import java.text.ParseException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.logging.Level; import java.util.logging.Logger; public class DBVerbindung { /** * @param args the command line arguments */ public static void verbindung() throws ParseException { try { String db_file_name_prefix = "C:\\Users\\Andreas\\workspace\\TinaProjekt\\src\\Name.sql"; Connection con = null; // Load the HSQL Database Engine JDBC driver // hsqldb.jar should be in the class path or made part of the current jar Class.forName("com.mysql.jdbc.Driver"); // connect to the database. This will load the db files and start the // database if it is not alread running. // db_file_name_prefix is used to open or create files that hold the state // of the db. // It can contain directory names relative to the // current working directory con = DriverManager.getConnection("jdbc:mysql:file:" + db_file_name_prefix, // filenames "sa", // username ""); // password Statement statement = con.createStatement(); //look at " for table name ResultSet rs = statement.executeQuery("SELECT * FROM Name"); //print the result set while (rs.next()) { System.out.print("Schirm: " + rs.getString("Name")); } statement.close(); con.close(); } catch (SQLException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); ex.printStackTrace(); } catch (ClassNotFoundException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } } public void schliesseVerbindung() { Connection con = null; Statement stmt = null; try { stmt.close(); con.close(); } catch (SQLException sqle) { System.out.println(sqle.toString()); } } }
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.46 / 8
188 Votes
http://codebin.yi.org/1267
page generated in 0.00 seconds