Java Sql Tutorial

SQL and Java JDBC • JDBC is a Java API for database connectivity • It is not the same as ODBC but implements a similar specification • JDBC enables programmers to write java.

Active6 years ago

This isn't a code question for once, but it definitely has me confused.

Java Sql Tutorial

Basically, my lecturer has told me that we have a project due next semester that involves us to use Java and SQL intertwined with each other.

I had no idea the combining of languages was even possible!

So my mind's really blown.

I've been searching around looking for examples of such code but no luck. So I thought I'd ask you guys.

I think the most logical thing to do since I have no experience with combining would be too create tables in SQL due too its use in databases and call them through Java.

Can anyone explain to me how this is possible or just the jist of how languages combine.

Thomas Owens
72.7k91 gold badges284 silver badges420 bronze badges
OVERTONEOVERTONE
5,31720 gold badges57 silver badges84 bronze badges

6 Answers

What you will probably be doing is using JDBC to allow Java to connect to SQL databases. There are also persistence layers, such as Hibernate, that you can use to store and retrieve data in a database using Java.

I think the JDBC tutorials should be enough to get you started. Just don't get in too far over your head too early. Take your time and ask questions as they come up.

Thomas OwensThomas Owens
72.7k91 gold badges284 silver badges420 bronze badges
  • Connect to a database
  • Do something interesting with it

You could start from here: http://java.sun.com/docs/books/tutorial/jdbc/index.html
Follows a brief example took from the link, so you can get a general grasp of what this is about:

As others pointed out this could get far from this, adding ORM, but I think knowing what JDBC is is a good start.

Alberto ZaccagniAlberto Zaccagni
24.9k8 gold badges64 silver badges99 bronze badges

The standard API to work with databases in Java is JDBC.

See Sun's Java Tutorials: JDBC Database Access.

JesperJesper
161k38 gold badges267 silver badges306 bronze badges

Surely your course will have provided reading on this. Start there.

The way of doing it involves using JDBC (Java database connectivity) in Java Sun Java doc on JDBC

Java Mysql Tutorial

The way is as you say 'create tables in SQL due too its use in databases and call them through java.'

So you will need to start learing relational datbase theory - see books by e.g. C. Date - inluding 'An Intorduction to Database Systems'

MarkMark
28.9k10 gold badges83 silver badges106 bronze badges

This has probably been THE big middleware problem anyone has tried to solve in that industry in the recent past. Without any preference, more or less in the order of appearance, a couple of attempts to combine the two:

  • JDBC (everything else is built upon JDBC. Almost)
  • JPA (and all of its implementations, including TopLink and Hibernate)
  • Lots of other tools...

I agree with others. Before learning anything else, you should learn about JDBC. Here's an authoritative tutorial by Oracle:

Lukas EderLukas Eder
144k79 gold badges468 silver badges1027 bronze badges

Look on the internet for 'embedded SQL'. Then you'll see that this subject is quite common. Also you'll see that SQL can be combined with many different languages (e.g. Python).

Please, notice that additional layers (e.g. a java class library as SQLJ) may require a slightly diffent syntax. My advice is to start with plain SQL over JDBC.

robertnlrobertnl

Java.sql Package Tutorial

Not the answer you're looking for? Browse other questions tagged javasql or ask your own question.