help me out here
when i wana use the java jdbc to connect mysql database, i cann't understand what does the following means: Class.forName("com.mysql.jdbc.Driver").newInstance(); very appreciate your help
[209 byte] By [
lostagaina] at [2007-11-26 12:40:29]

A JDBC connection requires a driver that is specific to your DB. The line you gave simply creates a new DB driver for a MySQL DB.
There's no need for the .newInstance() part. Simply loading the class with the Class.forName() does what you need done.
See this page for some basic intro info on JDBC.
http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html
Hope this helps.
I helped you out. Are you gonna dish out some of those shiny Duke Dollars you promised?
> I helped you out. Are you gonna dish out some of> those shiny Duke Dollars you promised?Hasn't happened yet so probably not. But there's a first time for everything.
I take extra time to earn some Duke Dollars in the hopes that when I post a question, people will give me a little help since I've been helpful to the community. However, when people offer 10 Dukes, get the answer they asked for, and still don't give out even 1, that fouls up the whole system. Oh well, not everybody can be expected to be nice.
The "Class.forName()" stuff is what loads the driver
Already answered in post #2, but no Dukes. In fact, 'lostagin' has at least 3 questions posted, all which have been answered, and no Dukes have been given out for them yet.
> Already answered in post #2, but no Dukes. In fact,> 'lostagin' has at least 3 questions posted, all which> have been answered, and no Dukes have been given out> for them yet.It happens all the time. Theres nothing you can really do about it.
there should be a policy,,, if you dont give the promised duke dollar, then you are tagged to a star of a BIG LIAR, and no should help you
bleh, I've been answering questions here since 1998 and rarely gotten any.Not that I mind much, but if you promise to do something you should do it.
i'm sorry ,you know i am an new fish here ,not well know about the duke ,all i know is when i assign more duke dollars ,there will be answers, can you tell me all about this ,
oh god ,you wanna police to punish the innocent one, if you tell me how to assign, than i will do that. and thank you very much..
> if you tell me how to assign, than i will do> that. and thank you very much..There should be an icon or something like that you can click on.
In the header section of each posting there should be a little Duke icon with a little + sign on it. If you think a posting was helpful, just click on the little icon. It will ask you how many Dukes to reward to the author of the post.
It works fine
Usually when u want to get Connection to a Database
1. Load the driver using Class.forName (Load's the driver into memory and Registers with DriverManager)
2. Get Connection with DriverManager
or we can directly create new instance like
OracleDriver od=new OracleDriver()(Dirctly Crateing the instance)
In you'r case
Class.forName() loads the driver and gives the Class object for that class you'r loading and by calling newInstance() u'r going to getObject for that class .after u'r down cast to u'r class
u'r code may look like//im writing oracle driver here
Object o=Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
OracleDriver or=(OracleDriver)o;
does it work ,by the way ,appreciate your help..hope you can always help me out..
> I take extra time to earn some Duke Dollars in the
> hopes that when I post a question, people will give
> me a little help since I've been helpful to the
> community. However, when people offer 10 Dukes, get
> the answer they asked for, and still don't give out
> even 1, that fouls up the whole system. Oh well, not
> everybody can be expected to be nice.
I don't think it a problem since the OP won't get any new dukes before he hands out these dukes.... or?