javaÎļþÁ¬½ÓmysqlÊý¾Ý¿âÂÒÂë - Java / Eclipse
ÏÖÔÚÕâ¸öÎÊÌ⻹ûÓнâ¾ö£¬ÎÒÔÚmyeclipseÖÐjdbcÁ¬½ÓmysqlÊý¾Ý¿â£¬ºóÀ´×öÁËÊý¾Ý²âÊÔ£¬É¾³ý£¬²éѯµÃµ½µÄÊý¾ÝºÜÕý³££¬µ«ÊÇ£¬²åÈëÊý¾Ý£¬Ö»ÒªÓÐÖÐÎÄ£¬ÓÀÔ¶¶¼ÊÇÂÒÂ룬°üÀ¨¸üÐÂÊý¾Ý£¬Ò²ÊÇÂÒÂë¡£¿´ÁËÍøÉÏ´ò´óƪµÄµÄÈçºÎ¸Ä£¬ÎÒ¶¼¸ÄÁË£¬¿ÉÊÇ»¹ÊDz»ÐС£Õâ¸öÎÊÌâ¿àÄÕËÄÌìÁË¡£ÕæÊǹ»·³È˵ġ£»¹ÇóÓÐÄÜÁ¦µÄ¸ø¸ö»Ø´ð¡£Ëµ·çÁ¹»°£¬ºÍ˵Á˵ÈÓÚûÓÐ˵µÄÇë±ðÀË·ÑÐÄÇé¡£
ÏÂÃæÌṩ×ÊÁÏ¡£
Õâ¸öÊÇÁ¬½ÓjdbcµÄURL
import java.sql.*;
public class ConnectionManager {
private static final String DRIVER_CLASS="com.mysql.jdbc.Driver";
//url="jdbc:mysql://localhost:3306/examonline?useUnicode=true&characterEncoding=GBK"
private static final String DATABASE_URL="jdbc:mysql://localhost:3306/newsdb";
private static final String DATABASE_USER="root";
private static final String DATABASE_PASSWORD="3022103";
public static Connection getConnection()
{
Connection dbcon=null;
try {
Class.forName(DRIVER_CLASS);
dbcon=DriverManager.getConnection(DATABASE_URL, DATABASE_USER, DATABASE_PASSWORD);
} catch (Exception e) {
e.printStackTrace();
}
return dbcon;
}
PS Á¬½ÓÍêÈ«Õý³££¬Ã»ÓÐÒ»µãÎÊÌâ¡£
ÏÂÃæÊÇÎÒÔÚmysql´´½¨Êý¾Ý¿âÒÔ¼°²åÈëµÄÊý¾ÝÖµ£¬Ò²Ã»ÓÐÎÊÌâ¡£
CREATE DATABASE newsdb;
USE newsdb;
DROP TABLE IF EXISTS FristTitle;
CREATE TABLE FristTitle(id INT UNSIGNED NOT NULL AUTO_INCREMENT,
FristName VARCHAR(50) NOT NULL,
creator VARCHAR(50) NOT NUL
Ïà¹ØÎÊ´ð£º
JSPÒ³ÃæÖÐÓжà¸öradio°´Å¥
JSPÒ³Ã潫²ÎÊýPOST¸øservlet
ÒªÇóÈçÏÂ;
1.Ñ¡ÔñÒ»¸öradio£¬µ÷ÓÃservlet servletÖиù¾Ý²ÎÊýµ÷ÓÃÆäËû½Ó¿Ú£¬³ý·ÇÑ¡ÖиÃradio²¢µã»÷JSPÖеÄʵР......
ÎÒÊǸöÐÂÊÖ£¬Íû¸ßÊÖ½â´ð
ÎÒÏÖÔÚÒѾ°²×°ÁËmysql£¬Ò²ÓÐmysqlµÄjdbc¡£µ«ÎÒÔõôÅäÖú󣬲ÅÄÜÔÚMyEclipseÀï²Ù×÷mysqlÄØ£¿Çë¸ßÊÖ˵Ïêϸµã
´ò¿ªMyeclipse----window---open perspective---MyEclipse database explorer-- ......
È磺 @superwaring("unchecked");
Õâ¸öÀïÃ涼¿ÉÒÔÈ¡ÄÄЩֵ°¡£¬»¹ÓÐÀàËÆµÄ @superwaring±êÇ©ÓÐÄÄЩ°¡
ûÓùý¡£¡£
¿´jeeµÄapi
javax.persistenceÀï
@superwaring("unchecked");Ö»ÊǺöÂÔ ......
´ó¼ÒºÃ£¬ÎÒÏÖÔÚÓÐÒ»¸öÓÃaspдµÄÁÄÌìÊÒ£¬ÏÖÔÚµÄÏëÌí¼ÓÒ»¸ö¹¦ÄÜ£¬¾ÍÊǵ±ÓÐÈËÉÏÏßµÄʱºò£¬·¢³öÌáʾ£¬±ÈÈçÉùÒôÏìһϣ¬ÏÖÔÚÏëÓÃjavaʵÏÖÕâ¸ö¹¦ÄÜ£¬ÇëÎÊ´ó¼ÒÔõôʵÏÖ£¿
ллÁË£¬ÎÒ»á¼Ó·ÖµÄ
aspºÍjavaÕûºÏµ½Ò»ÆðÈ¥£¿ºÎ±Ø ......
ÔõôÑù½«id´«¹ýÈ¥°¡£¿£¿£¿ÊǼòµ¥µÄ´«¡£¡£¡£ÔÚµØÖ·À¸ÖÐдidºÅ
LZ ºÃÓÄĬ£¡²»ÖªµÀÄãµÄÒâ˼£¿
ÊÇÏë°ÑID ´«µ½ACTION ? ͨ¹ýURl id=?
²»¹»Ïêϸ ±ðÈ˲»ÖªµÀÔõÑù°ïÄã
../XXXXX.do?id=XXXX&id2=XXXXX
......