Á¬½Óoracle£¬sqlserverÖÐÊý¾Ý¿âµÄʾÀý´úÂë
Ò» ÔÚOracleÖÐÁ¬½ÓÊý¾Ý¿â
public class Test1 {
public static void main(String[] args) {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(
Ö÷»úÃû ¶Ë¿Ú SID ÕʺŠÃÜÂë
"jdbc:oracle:thin:@haha:1521:oracle", "hehe", "a");
Statement stt = conn.createStatement();
ResultSet rs = stt.executeQuery("select * from emp");
while (rs.next()) {
System.out.print(rs.getObject(2).toString());
System.out.println("\t" + rs.getObject(3).toString());
}
rs.close();
stt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
¶þ ÔÚsqlserverÖÐÁ¬½ÓÊý¾Ý¿â
public class DBManager {
String url="jjdbc:microsoft:sqlserver://localhost:1433;databaseName='student'";
String driver ="com.microsoft.jdbc.sqlserver.SQLServerDriver";
String useName="sa";
String pwd="sa";
Connection con =null;
Statement sta=null;
ResultSet rs=null;
public ResultSet getQiery(String sql)
{
try {
Class.forName(driver);
con =DriverManager.getConnection(url,useName,pwd);
sta = con.createStatement();
rs =sta.executeQuery(sql);
} catch (Exception e) {
e.printStackTrace();
}
return rs;
}
public int getUpd(String sql)
{
int i=0;
try {
&nb
Ïà¹ØÎĵµ£º
Êýѧº¯Êý
ÔÚoracle ÖÐdistinct¹Ø¼ü×Ö¿ÉÒÔÏÔʾÏàͬ¼Ç¼ֻÏÔʾһÌõ
¡¡¡¡1.¾ø¶ÔÖµ
¡¡¡¡S:select abs(-1) value
¡¡¡¡O:select abs(-1) value from dual
¡¡¡¡2.È¡Õû(´ó)
¡¡¡¡S:select ceiling(-1.001) value
¡¡¡¡O:select ceil(-1.001) value from dual
¡¡¡¡3.È¡Õû£¨Ð¡£©
¡¡¡¡S:select floor(-1.001) value
......
ÓÉÓÚ¹¤×÷ÐèÇó£¬Òª¶Ô¸ºÔðµÄ²ú Æ·×öµãÐÔÄÜÓÅ»¯£¬ÔÚÍøÉÏÕÒµ½ÁËÏà¹ØµÄ¶«Î÷£¬Äà ³öÀ´Óë´ó¼Ò·ÖÏí£º
¿´µ½ºÜ¶àÅóÓѶÔÊý¾Ý¿âµÄÀí½â¡¢ÈÏʶ»¹ÊÇûÓÐÍ»ÆÆÒ»¸öÆ¿¾±£¬¶øÕâ¸öÆ¿¾±ÍùÍùÖ»ÊÇÒ»²ã´°Ö½£¬Ô½¹ýÁËÄ㽫¿´µ½Ò»¸öÐÂÊÀ½ç¡£
04¡¢05Äê×öÏîÄ¿µÄʱºò£¬ÓÃSQL Server 2000£¬ºËÐÄ±í£¨´ó²¿·ÖʹÓÃƵ·±µÄ¹Ø¼ü¹¦ÄÜÿ´Î¶¼ÒªÓõ½£©´ïµ½ÁË800ÍòÊý¾Ý ......
=================·ÖÒ³==========================
/*·ÖÒ³²éÕÒÊý¾Ý*/
CREATE PROCEDURE [dbo].[GetRecordSet]
@strSql varchar(8000),--²éѯsql,Èçselect * from [user]
@PageIndex int,--²éѯµ±Ò³ºÅ
@PageSize int--ÿҳÏÔʾ¼Ç¼
AS
set nocount on
declare @p1 int
declare @current ......
· ±¾ÎÄÌÖÂÛÁËÈçºÎͨ¹ýTransact-SQLÒÔ¼°ÏµÍ³º¯ÊýOPENDATASOURCEºÍOPENROWSETÔÚͬ¹¹ºÍÒì¹¹Êý¾Ý¿âÖ®¼ä½øÐÐÊý¾ÝµÄµ¼Èëµ¼³ö£¬²¢¸ø³öÁËÏêϸµÄÀý×ÓÒÔ¹©²Î¿¼¡£
1. ÔÚSQL ServerÊý¾Ý¿âÖ®¼ä½øÐÐÊý¾Ýµ¼Èëµ¼³ö
(1).ʹÓÃSELECT INTOµ¼³öÊý¾Ý
  ......
1.Èç¹ûÏÈprepare ºóÌí¼Ó²ÎÊý£¬ÕâÑùÒ»²¿·ÖÊý¾ÝÀàÐÍ¿ÉÒÔ²»ÓÃÉèÖÃÆäsize´óС£¬ÀýÈçchar
2.Èç¹ûÏÈÌí¼Ó²ÎÊýÔÙprepare£¬¾Í±ØÐëÉèÖòÎÊýµÄÀàÐÍ£¬´óС£¬¾«¶È²ÅÄÜͨ¹ý£¬±ÈÈçchar,varchar,decimalÀàÐÍ£¬¶øint,floatÓй̶¨×Ö½ÚÀàÐ͵ÄÊý¾ÝÀàÐÍÔò¿É²»ÓÃÉèÖôóС¡£
3.¹ØÓÚSqlServerµÄtimestampÀàÐÍ£º¸ÃÀàÐÍΪSqlServerµÄʱ¼ä´ÁÀàÐÍ£¬´´½ ......