Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : java

JAVAµ÷ÓÃMYSQL´æ´¢¹ý³Ì

JAVAµ÷ÓÃMYSQL´æ´¢¹ý³Ì
¹¤³ÌÊÓͼ£º
´úÂëÇåµ¥£º
myconn.java
package org.apache.sh_mysql.test;
import java.sql.*;
public class MyConn {

private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=GBK";
private static final String USER = "root";
private static final String PASSWORD ="root";
static {
try {
Class.forName(DRIVER);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* »ñÈ¡Á¬½Ó
*
* @return
* @throws Exception
*/
public Connection getConnection() throws Exception {
return DriverManager.getConnection(URL, USER, PASSWORD);
}
/**
* ÊÍ·Å×ÊÔ´
*
* @param rs
* @param statement
* @param conn
*/
public void close(ResultSet rs, CallableStatement stmt, Connection conn) {
try{
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn. ......

JAVAµ÷ÓÃMYSQL´æ´¢¹ý³Ì

JAVAµ÷ÓÃMYSQL´æ´¢¹ý³Ì
¹¤³ÌÊÓͼ£º
´úÂëÇåµ¥£º
myconn.java
package org.apache.sh_mysql.test;
import java.sql.*;
public class MyConn {

private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=GBK";
private static final String USER = "root";
private static final String PASSWORD ="root";
static {
try {
Class.forName(DRIVER);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* »ñÈ¡Á¬½Ó
*
* @return
* @throws Exception
*/
public Connection getConnection() throws Exception {
return DriverManager.getConnection(URL, USER, PASSWORD);
}
/**
* ÊÍ·Å×ÊÔ´
*
* @param rs
* @param statement
* @param conn
*/
public void close(ResultSet rs, CallableStatement stmt, Connection conn) {
try{
if (rs != null) {
rs.close();
}
if (stmt != null) {
stmt.close();
}
if (conn != null) {
conn. ......

Java³ÌÐòÏà¹ØÎÊÌâ


JAVA³ÌÐò
JAVA API      JAVA  ÐéÄâ»ú
JAVA  ÐéÄâ
²Ù×÷ϵͳ
Ó²¼þƽ̨
1.Java³ÌÐòÏà¹ØÎÊÌâ——JavaÐéÄâ»ú
      JavaÐéÄâ»ú——ÔÚÕæʵ»úÆ÷ÖÐÓÃÈí¼þÄ£ÄâʵÏÖµÄÒ»ÖÖ³éÏóµÄ»úÆ÷¡££¨JavaÐéÄâ»ú¹æ·¶£©
      JavaÐéÄâ»úÖ÷ÒªÓÉÎå¸ö²¿·Ö×é³É£ºÖ¸Áîϵͳ¡¢¼Ä´æÆ÷¡¢Õ»¡¢´æ´¢Çø¡¢ËéƬ»ØÊÕÇø
      ½âÊͺÍÖ´ÐÐJava³ÌÐò±àÒëºó²úÉúµÄ×Ö½ÚÂë
2.Java³ÌÐòÏà¹ØÎÊÌâ——Java API
      Java APIÊÇJavaϵͳÌṩµÄÔ¤Ïȶ¨ÒåºÃµÄÈí¼þ×é¼þµÄ¼¯ºÏ£¬ËüÃÇÌṩÁËÐí¶à¿É¹©³ÌÐòÔ±µ÷Óõij£Óù¦ÄܷḻµÄAPIΪ³ÌÐòÔ±ÌṩÁ˼«´óµÄ·½±ã£¬µ«Ò²ÊÇѧϰµÄÄѵã
      Ҫѧ»áʹÓÃJava APIÊÖ²á(The Java 2 Platform API Specification )
3.Java³ÌÐòÏà¹ØÎÊÌâ—— Java³ÌÐòµÄÔËÐлúÖÆ
  ´«Í³ÓïÑÔµÄÔËÐлúÖÆ£º
      Ô´´úÂë→(±àÒë)→Ä¿±êÂë→£¨Á¬½Ó£©→¿ÉÖ´ÐдúÂë→£¨ÔËÐУ©→¡¾²Ù×÷ϵͳ¡¿
  JavaÓïÑÔµ ......

´«ÖDz¥¿ÍJAVAÅàѵstruts2ѧϰ±Ê¼ÇÒ»

´«ÖDz¥¿ÍJAVAÅàѵstruts2ѧϰ±Ê¼ÇÒ»
   
Àë±ÏÒµÓÖ×ß½üÁËÒ»²½£¬ÐÄÀïÓÖĪÃûµÄ½ôÕÅÆðÀ´¡£½ñÌìÓÐÒ»¸öͬÐĹ«Ë¾·Å¼ÙÐÇÆÚѧУÀ´ÉϿΣ¬ÎÒ¶ÔÆä³ýÁËÅå·þÖ®Í⣬¾ÍÖ»ÓÐÏÛĽÁË£¬¹¤×Ê6.5£Ë¿É²»ÊÇÎÒÏÖÔÚµÄˮƽ
¸ÒÏëµÄºÇ£¬ËäÈ»ÎÒ¶Ô£³£Ç²»ÊǺܸÐÐËȤ£¬ÎÒÒ²¸üÏàÐŽÅ̤ʵµÄÈ¥×ߺÃÿһ²½À´µÃ̤ʵ£¡µ«ÊÇÕ⼸¸öͬѧËùÈ¡µÃ³É¼¨È´ÊÇÎÒÃÇÈ«°àͬѧ²»µÃ²»Åå·þµÄ£¬Í¬Ê±£¬ÎÒÃǵÄѹ
Á¦Ò²ÊǸоõµ½·Ç³£´óµÄ£¬ÒòΪËûÏÖÔڵŤ×ÊÒÔ¼°ËûÃÇÔÚÄÇô¶ÌµÄʱ¼ä¾ÍÈ¡µÃÁËÕâôºÃµÄ³É¼¨£¬¶ÔÎÒÃÇ´øÀ´µÄѹÁ¦Ò²ÊÇͦ´óµÄºÇ£¡µ«ÊÇ£¬ÎÒ²»»áÔÚÕâÆäÖоͰÑ×Ô¼ºµÄÄ¿
±ê¶¨µÄ·Ç³£µÄ¸ß£¬ÒòΪÎҵÿ´Çå×Ô¼ºµÄʵÁ¦°É£¬²»ÊÇÎÒ¿´µÍÎÒ×Ô¼º£¬ÎÒÊÇ¿´µÃÇå×Ô¼º£¡µ«Ô¸ËùÓеÄÒ»Çз¢Õ¹¶¼ÏñһλÕÜÈ˽²¹ýµÄ»°£¬´ó¸ÅÒâ˼ÊÇÕâÑù£ºÖ»ÒªÄãÏàÐÅ×Ô
¼ºµÄδÀ´ÊÇÃÀºÃµÄ£¬Ö»ÒªÄãһֱŬÁ¦µÄ·Ü¶·ºÍÆ´²«£¬ËùÓеÄÒ»ÇоͻáºÃµÄ¡£ÔÛÃǾ͓Æï¿¿´³ª±¾£¬×ß×ÅÇÆ£¡”¡£
¡¡¡¡Í¨¹ý½ñÌìÒ»ÌìµÄѧϰ,¶ÔSTRUTS2Ò²ÓÐÁËÒ»¶¨µÄÁ˽â,struts2ÓëstrutsÏà¶Ô֮ϣ¬ÎÒÏÖÔÚ¶ÔstrutsËäȻ˵²»ÊÇÉϾ«Í¨£¬µ«ÔÚÈý´ó
ssh¿ò¼ÜÖÐÕÆÎÕ×îÊìÁ·µÄ¾ÍÊÇstruts£¬ËäȻѧϰÁ˸ÃÊÇ¿ò¼ÜÖ®ºó¶ÔÏÖÔÚѧϰstruts2ÓкܴóµÄ°ïÖú£¬±ãÊÇÎÒÃ÷È·µÄ¸Ð¾õµ½ÁËÁ½ÕßÖ®ÕßÊǸ÷×Ô²»Í¬µÄ¶«
¶«¡£²¢Ç ......

Java Óë ¸»Ê¿¿µ

¸´Ï°Ò»ÏÂjava´úÂ룬´úÂëÎÊÌâºÜ¶àÇë¸ßÊÖ²»Áߴͽ̡£°ïÖúÖع¹¡£
public static void main(String[] args){
    int employeeCount = 420000;  //Ô±¹¤×ÜÊý 
    Employee[] ËùÓÐÖ°¹¤  = getAllEmployee();
    for((i=0;i<=employeeCount ;i++) {
      Employee Ô±¹¤ = ËùÓÐÖ°¹¤[i];
      if(Ô±¹¤.¹¤×÷µ¥Î»().Ãû³Æ().equals("¸»Ê¿¿µ") ){
             Ô±¹¤.ÌøÂ¥();
      }
  }
} ......

´¿java PHPÒýÇæ——Quercus

ÓÉÓÚ¹«Ë¾ÏîÄ¿µÄÐèÒª£¬×î¾­ÔÚÑо¿QuercusÒ»¸ö´¿javaµÄphpÒýÇæ¡£ÏîÄ¿ÕâÁ½¸öÐèÒª×öµÄ¾ÍÊǽ«¸ÃÒýÇæ²Ã¼ô£¬×öÒ»¸öÏà¶Ô°²È«µÄ°æ±¾£¬Ìṩ¸øISVʹÓã¬Í¬Ê±£¬ÔÚÒýÇæÖÐÌṩĬÈϵĽӿڹ©µ÷Óá£ËùÒÔÏÈÑо¿ÁËһϣ¬ÔÚQuercusÒýÇæµÄÖ§³ÖÏ£¬PHPÈçºÎÓëjava¼¯³É¡£
ÒÔÏÂÊÇѧϰµ½µÄ¼¸µã£º
1¡¢Èç¹ûʹÓàResin-IoC/WebBeansÀ´×éÖ¯Ó¦ÓõķþÎñµ½½Å±¾ÖУ¬ÄÇô½Å±¾ÖоͿÉÒÔÖ±½Ó»ñÈ¡µ½ÅäÖõķþÎñµÄµ¥ÀýʵÀýµÄÒýÓã¬Ê¹Ó÷½Ê½ÈçÏÂ
<?php
$demo_manager = java_bean("DemoeManager");
$demo = $demo_manager->findData("demoId");
foreach ($demo->getDatas() as $data) {
echo $data . "\n";
}
?>
2¡¢ÁíÍâÒ»ÖÖ¿ÉÒÔͨ¹ýnew Java()·½Ê½£¬ÒÔclassÍêÕûÃû³ÆÒÔ¼°¹¹Ô캯Êý²ÎÊý×÷Ϊ²ÎÊýÀ´Éú³É¶ÔÓ¦µÄjava ¶ÔÏó£¬ÀýÈç
<?php
$a = new Java("java.util.Date", 123);
echo $a->time;
?>
3¡¢Quercus»¹Ö§³Ö£¬ÀàËÆÓÚjava µÄÒýÓ÷½Ê½£¬¼´£¬ÔÚPHPÖÐʹÓÃimportÓï¾äÒýÈëclass£¬Ê¹ÓÃnew¹Ø¼ü×ÖÀ´´´½¨¶ÔÏó¡£
<?php
import java.util.Date;
$a = new Date(123);
echo $a->time;
?>
Èç¹ûÊÇʹÓÃResin¿ò¼Ü£¬»á×Ô¶¯¼ÓÔØ WEB-INF/classes/classnam ......

´¿java PHPÒýÇæ——Quercus

ÓÉÓÚ¹«Ë¾ÏîÄ¿µÄÐèÒª£¬×î¾­ÔÚÑо¿QuercusÒ»¸ö´¿javaµÄphpÒýÇæ¡£ÏîÄ¿ÕâÁ½¸öÐèÒª×öµÄ¾ÍÊǽ«¸ÃÒýÇæ²Ã¼ô£¬×öÒ»¸öÏà¶Ô°²È«µÄ°æ±¾£¬Ìṩ¸øISVʹÓã¬Í¬Ê±£¬ÔÚÒýÇæÖÐÌṩĬÈϵĽӿڹ©µ÷Óá£ËùÒÔÏÈÑо¿ÁËһϣ¬ÔÚQuercusÒýÇæµÄÖ§³ÖÏ£¬PHPÈçºÎÓëjava¼¯³É¡£
ÒÔÏÂÊÇѧϰµ½µÄ¼¸µã£º
1¡¢Èç¹ûʹÓàResin-IoC/WebBeansÀ´×éÖ¯Ó¦ÓõķþÎñµ½½Å±¾ÖУ¬ÄÇô½Å±¾ÖоͿÉÒÔÖ±½Ó»ñÈ¡µ½ÅäÖõķþÎñµÄµ¥ÀýʵÀýµÄÒýÓã¬Ê¹Ó÷½Ê½ÈçÏÂ
<?php
$demo_manager = java_bean("DemoeManager");
$demo = $demo_manager->findData("demoId");
foreach ($demo->getDatas() as $data) {
echo $data . "\n";
}
?>
2¡¢ÁíÍâÒ»ÖÖ¿ÉÒÔͨ¹ýnew Java()·½Ê½£¬ÒÔclassÍêÕûÃû³ÆÒÔ¼°¹¹Ô캯Êý²ÎÊý×÷Ϊ²ÎÊýÀ´Éú³É¶ÔÓ¦µÄjava ¶ÔÏó£¬ÀýÈç
<?php
$a = new Java("java.util.Date", 123);
echo $a->time;
?>
3¡¢Quercus»¹Ö§³Ö£¬ÀàËÆÓÚjava µÄÒýÓ÷½Ê½£¬¼´£¬ÔÚPHPÖÐʹÓÃimportÓï¾äÒýÈëclass£¬Ê¹ÓÃnew¹Ø¼ü×ÖÀ´´´½¨¶ÔÏó¡£
<?php
import java.util.Date;
$a = new Date(123);
echo $a->time;
?>
Èç¹ûÊÇʹÓÃResin¿ò¼Ü£¬»á×Ô¶¯¼ÓÔØ WEB-INF/classes/classnam ......

¡¾JAVAѧϰ±Ê¼Ç¡¿01 ±êÖ¾·ûºÅ¡¢¹Ø¼ü×Ö¡¢ÀàÐÍ

Ò»¡¢JAVAÖж¨ÒåÁËÈýÖÖ×¢ÊÍÀàÐÍ£º
//µ¥ÐÐ×¢ÊÍ——×¢Ê͵½ÐÐβ
/*¶àÐÐ×¢ÊÍ*/
/**¿ÉÒÔÓÃÓÚÎĵµ´¦ÀíµÄµ¥ÐлòÕ߶àÐÐ×¢ÊÍ*/
// µ¥ÐÐ×¢ÊÍ
/*
¶àÐÐ×¢ÊÍ£¬´ËÄÚÈÝÒ²²»»á±»Ö´ÐÐ
*/
/**
Îĵµ×¢ÊÍ£¬ÓÐרÃŵŤ¾ß
*/
public class JavaDemo01
{
// Ö÷·½·¨
public static void main(String args[])
{
// ÔÚ×îºó¼ÓÒ»¸ö“;”±íʾÓï¾äµÄÍê½á
System.out.println("Hello MLDN .") ;
System.out.println("Hello LXH .") ;
}
}; 
¶þ¡¢±äÁ¿£º
³ÌÐòÖ´ÐÐÖÐÊýÖµ¿ÉÒÔ±äµÄÊý¾Ý³ÆΪ±äÁ¿¡£±äÁ¿°üÀ¨±äÁ¿ÃûºÍ±äÁ¿Öµ
±äÁ¿Ãû£ºÓñêʶ·ûÃüÃû¡£
±êʶ·û£º·ûºÏÒ»¶¨ÃüÃû¹æÔòµÄ×Ö·û´®ÐòÁС£
±äÁ¿¹¹³ÉÁËÕû¸ö³ÌÐòµÄ¹Ø¼ü¡£
public class JavaDemo02
{
// Ö÷·½·¨
public static void main(String args[])
{
// ±äÁ¿¶¨ÒåµÄ¸ñʽ£º±äÁ¿µÄÀàÐÍ ±äÁ¿µÄÃû³Æ = ³õÖµ ;
int x = 30 ;
int y = 20 ;
// ÐÞ¸ÄxµÄÄÚÈÝ£º±äÁ¿Ãû³Æ = ÐÂÖµ
x = 50 ;
// ´òÓ¡ x + yµÄÖµ
System.out.println(x + y) ;
}
}; 
ʹÓñäÁ¿µÄ×¢ÒâÊÂÏ
±äÁ¿ÃüÃû²»ÄÜÖظ´
JAVAÇø·Ö´óСд
±äÁ¿±ØÐëÏȶ¨ÒåºóʹÓÃ
Èý¡¢±êʶ·û
±êʶ·û¾ÍÊÇÒ»¸ö¼ÇºÅ£¬×é³É£º×Ö ......
×ܼǼÊý:6386; ×ÜÒ³Êý:1065; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [11] [12] [13] [14] 15 [16] [17] [18] [19] [20]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ