I am for the classmate to do a Java-ee about the struct+hibernate structure of the class, the database used to be Oracle, the database is missing, do not want to install Oracle, that thing installed in the book too knife, can not remove nausea ... To change a MySQL to him to change, some of the online posts, too old, version and Web site are refurbished did not turn content, the first big, not to force Ah, or can not rely on the network, after all, some things to believe themselves-think of their own try. Thinking is the king.
These are all nonsense. Start:
MyEclipse the MySQL database before connecting to these items:
Steps:
1. Install Jdk,tomcat,myeclipse (now MyEclipse8.5 is all encapsulated, no eclipse required, of course, I personally think to try Eclipse build platform)
A wordy remark:
There are many kinds of eclipse version, which according to their own development purposes, their own intentions to find the necessary development version, eclipse3.5 Galileo version +joss Tools (plug-ins) +myeclipse plug-ins, enough, such a hands-on, can understand. Do not rely on bindings, because the visualization has become less, the configuration file is all handwritten, write Juint Test yourself.
Above the nonsense enough you develop to struct +hibernate+spring to carry on the Java-EE heavyweight development.
url:http://www.eclipse.org/downloads/
Screenshots:
2. MyEclipse Connect MySQL needs of the Connect Driver (I have, who want to leave me a mailbox, I send you, the company to take the noon to the needs of mass),
This also gives the official address: Figure: Detailed callout, detailed step diagram
Then:
Then:
Then:
Next there will be Europe, some Asian version, remember: Basic, I chose the American version, whichever is OK.
Plugin has, what is next to prepare it? --> install MySQL, this I do not elaborate, because I think the problem of installing MySQL is only one: User name and password remember!!!
Official Entry theme:
Look directly at the picture, I think I talk stupid, direct screenshots, nonsense said more will be scolded.
1.
Note: The double arrow is because both of these choices are the same result.
2.
3.
Click Finish to complete the database-driven connection.
4.
Opening a connection is----test database configuration is successful-----as long as you are not naughty, you will surely succeed!!!
5. Next add a bundle of MySQL data connections:
Do not write, the next time I edited, is actually a point next, and then see a name: Mysqljars point to the right addjars, and then find your
Click Finish, finish, finish ....
And then in your project to see a Java class, test, OK, of course, you have to have a database to do, I will first put the Code and class code are posted up
Class name: whatever.
Package com.bipt.db;
Import java.sql.Statement;
Import java.sql.Connection;
Import Java.sql.DriverManager;
Import Java.sql.ResultSet;
Import java.sql.SQLException;
public class Dbcon {public static Connection conn=null;
public static Statement stmt = null;
public static ResultSet rs = null;
public void Getcon () throws ClassNotFoundException, SQLException {class.forname ("com.mysql.jdbc.Driver");
conn = Drivermanager.getconnection ("Jdbc:mysql://localhost/btestdemo?")
+ "User=root&password=bipt");
The public void Closecon (Connection conn) throws SQLException {if (conn!= null) Conn.close ();
public static void Main (string[] args) {Dbcon DBC = new Dbcon ();
try {Dbc.getcon ();
stmt = Conn.createstatement ();
rs = Stmt.executequery ("SELECT * from user");
while (Rs.next ()) {System.out.println (Rs.getint ("USERID"));
System.out.println (rs.getstring ("USERNAME"));
System.out.println (rs.getstring ("UserPassword")); System.out.println (RS.GEtstring ("Usermail"));
System.out.println (Rs.getdate ("Usertime"));
System.out.println (rs.getstring ("userintegral"));
System.out.println (rs.getstring ("Usersex"));
System.out.println ();
} System.out.println ("conn:" + dbcon.conn);
System.out.println ("MySQL test success");
catch (ClassNotFoundException e) {//TODO auto-generated catch block E.printstacktrace ();
catch (SQLException e) {//TODO auto-generated catch block E.printstacktrace ();
}
}
}
MySQL script:
CREATE TABLE ' user ' (
' USERID ' int (one) not null auto_increment,
' USERNAME ' varchar () NOT NULL default ',
' U Serpassword ' varchar default ',
PRIMARY KEY (' id ')
) engine=innodb default charset=gb2312;
Go
Run this Java class, the console will display the database said there is user information, too late, sleep, another day edit, too messy.
I hope I can help you!