Night | Snow

Derby Db Verbindung in Java

Posted on: December 6th, 2009

Tags:

Grundsätzlich gibt es in Java 6 die folgenden beiden Möglichkeiten eine Verbindung mit einer JavaDB (Apache Derby) herzustellen. Entweder man verwendet den Derby Treiber (Variante 1) und stellt eine Verbindung mit dem Host her oder man geht über eine DataSource (Variante 2) und gibt das Datenbank-Verzeichnis an.

Variante 1:

try {
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
Connection con =DriverManager.getConnection("jdbc:derby://localhost:1527/db;create=true;user=admin;password=1234");
} catch (Exception e) {
}

Variante 2:

EmbeddedDataSource ds = new EmbeddedDataSource();
ds.setCreateDatabase("create");
ds.setDatabaseName("Users/simon/db");
try {
Connection con = ds.getConnection();
} catch (SQLException e) {
}

Posted in Java | Trackback Url

News

  • Facebook shares see modest debut

    Facebook shares end a volatile first day of trading at $38.23, barely above the company's initial pricing, having initially jumped more than 10%.

  • Met Police to extract phone data

    Mobile phone data of suspects in police custody is to be extracted and retained, regardless of whether charges are brought, the BBC has learned.

  • Silicon trick for next-gen memory

    Researchers reveal details of a promising way to make a fundamentally different kind of computer memory chip.

Martin Fischer said:

Client and partner of simra.ch

Wir können Simon Schärer als kompetenter und zuverlässiger Programmierer höchst weiterempfehlen. Er ist nicht nur ein guter Programmierer, sondern auch ein ausgezeichneter Designer.
Danke Developer’s Island

Follow us on Twitter

favorite

I get asked a lot - which SDK should we use for web programming? I recommend Netbeans

my toolbar

Simra GameMP3 playersubscribe to RSSMy delicious bookmarksFacebookTwitterE-mail

No Responses to “Derby Db Verbindung in Java”

RSS Feed Icon  Subscribe to comments follow-up

Trackbacks/Pingbacks

Leave a reply

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Latest Tweet

loading...