3月21日——培训第85天

 昨天的程序中还可以考虑添加菜单项,

关键代码(打开文件):

String filePath = "";
    File file = null;
    BufferedReader br;
    String content = "";
   
    public void jMenuItem2_actionPerformed(ActionEvent e) {
        if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
           file = fileChooser.getSelectedFile();
           filePath = file.getAbsolutePath();
           //JOptionPane.showMessageDialog(this,"file:" + filePath);
           try {
             br = new BufferedReader(new FileReader(file));
             content = br.readLine();
             while (content != null){
                 text.append(content + "/n");
                 content = br.readLine();
             }
           }catch(Exception ee){
               ee.printStackTrace();
           }
        
          
        }
    }

 

-----------------------------------------------------------
每个测试方法先调用@Before,然后调用测试方法@Test,再调用@After,
也就是说@Before和@After是每个测试方法都必须调用的!
其实就是那个SetUp和TearDown方法,只不过由于版本的不同导致称呼不同而已……

有一个@BeforeClass只调用一次

一个简单的测试示例如下:

package com.test;

import org.junit.*;
import static org.junit.Assert.*;

public class H1Test
{
 @Before
  public void m1()
 {
  System.out.println("before");
 }

 @Test
  public void t1()
 {
  System.out.println("1");
  assertEquals((1+1),2);
 }

 @Test
  public void t2()
 {
  System.out.println("2");
  assertEquals((1+2),3);
 }

 @After
  public void m2()
 {
  System.out.println("after");
 }

 @BeforeClass
  public static void m3()
  {
   System.out.println("start");
  };

 @AfterClass
  public static void m4()
  {
   System.out.println("stop");
  };

};

///java org.junit.runner.JUnitCore com.test.H1Test
//javac -d .

编译后执行下面的运行命令……
java org.junit.runner.JUnitCore com.test.H1Test


====================================================================

package com.test;

import org.junit.*;
import static org.junit.Assert.*;
import com.web.*;

public class H1Test
{
 H1 h1 = new H1();

 @Before
  public void m1()
 {
  System.out.println("before");
  
 }

 @Test
  public void t1()
 {
  System.out.println("1");
  assertEquals((1+1),2);
 }

 @Test
  public void t2()
 {
  System.out.println("2");
  assertEquals((1+2),3);
 }

 @Test
  public void t3()
 {
  System.out.println("3");
  assertEquals(h1.add(3,4),7);
 }

 @After
  public void m2()
 {
  System.out.println("after");
 }

 @BeforeClass
  public static void m3()
  {
   System.out.println("start");
  };

 @AfterClass
  public static void m4()
  {
   System.out.println("stop");
  };

};

///java org.junit.runner.JUnitCore com.test.H1Test
//javac -d .

td:testdirector Mercury
ibm:rose:cq:clearquest  (测试管理工具:生成测试计划和测试用例)
winrunner:自动化测试(主要用于黑盒测试,也就是功能测试,需要参考需求文档)
loadrunner:负载测试(压力测试):可以产生虚拟用户,比如产生虚拟用户1万人去检测软件

===========================================================================
oracle:
启动:服务器端进程、服务进程
1、启动服务器端进程 oracle sid(不是数据库名)
2、通过客户端进程连接服务器端进程 sqlplus /nolog (不登录:nologin)
3、连接到实例上 set oracle_sid=java (sid)

connect / as sysdba
/:区分用户名和密码:username/password,如果不写代表用户名和密码是任意的

4、启动数据库:startup
startup nomount :只加载实例
startup mount:加载控制文件

5、身份验证:有两种方式
1、通过操作系统身份验证
2、通过数据库验证

connect / as sysdba:通过操作系统验证:在数据库没有打开的时候只能使用这种方式

对登录到操作系统的用户要求必须是属于ora_dba组!
以操作系统身份验证登录映射数据库用户是sys用户

Connection conn = DataSource.getConnection() ;
CallableStatement cstmt = cn.prepareCall("{call insert_user ?,?,?}") ;

cstmt.registerOutParameter(1,Types.INTEGER);//设置输出参数
cstmt.setParameter(2,'zxx');//设置输入参数
cstmt.setParameter(3,'123');
cstmt.execute();
cstmt.getInt(1);//取出了下面存储过程返回的值(也就是刚才插入的用户的id),同时也插入了刚才的用户zxx

//@password和@name是输入参数,@id是输出参数,因为后面有个out!
create procedure insert_user(@id int out,@name varchar(20),@password varchar(20))
begin transaction
 insert into user(name,password) values(@name,@password);
 select @id=max(id) from user ;
commit

-------------------------------------
Oracle分页(第六天里面讲的)
select * from
(
 select last_name,rownum as id from employees
 where rownum<21
)
where id > 11 ;

既然不能够让rownum大于一个具体的非0值,那么先构造一个第一到20个
记录的表,这个表中把rownum的字段抽象成一个别名叫做id
这个id可以作为条件来选择……

这就是分页的解决方法了……在mysql中不支持rownum,所以只有oracle才能
用这种方法分页,mysql中有别的方法来分页!
------------------------------------------------------------------
一个Oracle的存储过程的示例:
package abc;

import java.sql.*;

public class H1
{
 public static void main(String[] args) throws Exception
 {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn = DriverManager
   .getConnection("jdbc:oracle:thin:@202.112.85.25:1521:webtest","scott","tiger");
  String procedure = "{ call savedata(?) }";
  CallableStatement cs = conn.prepareCall(procedure);
  cs.setInt(1,100);
  cs.executeUpdate();
  cs.close();
  conn.close();

 }
};

 

create table ht3
(
id int not null primary key,
name varchar(5) not null
);

 

create or replace procedure savedata
(i in number)
as
begin
insert into ht3 values (i,'s' || i);
end;
/


SQLServer的随机:

select top 5 * from sales order by newid()
//实现随机选5行的方法。
----------------------------------
SQLServer的分页:

select top 3 * from Grade where Player='选手一' and ID not in
        (select top 3 ID from Grade where player='选手一')
===========================================================

1. Given:

1. public class test (
2.   public static void main (String args[])    {
3.       int  i = 0xFFFFFFF1;
4.       int  j = ~i;
5. 
6.      }
7. )

What is the decimal value of j at line 5?

A. 0
B. 1
C. 14
D. -15
E. An error at line 3 causes compilation to fail.
F. An error at line 4 causes compilation to fail.

2. Given:

Integer i = new Integer (42);
Long 1 = new Long (42);
Double d = new Double (42.0);

Which two expressions evaluate to True? (Choose Two)

A. (i ==1)
B. (i == d)
C. (d == 1)
D. (i.equals (d))
E. (d.equals (i))
F. (i.equals (42))

3. Click the exhibit button:

1. public class test (   
2.          private static int j = 0;
3.       
4.        private static boolean methodB(int k) (
5.                j += k;
6.                return true;
7. )
8.
9. public static void methodA(int  i) {
10.          boolean b:  
11.          b = i < 10 | methodB (4);
12.          b = i < 10 || methodB (8);
13. )
14.
15.  public static void main (String args[] }   (
16.              methodA (0);
17.              system.out.printIn(j);
18.            )
19. )

What is the result?

A. The program prints “0”
B. The program prints “4”
C. The program prints “8”
D. The program prints “12”
E. The code does not complete

4. Given:

1.Public class test (
2.    Public static void main (String args[])  (
3.     System.out.printIn (6 ^ 3);
4.   )
5.)

What is the output?

Ans:


5. Given:

1. public class Foo {
2.   public static void main (String [] args)  {
3.      StringBuffer a = new StringBuffer (“A”);
4.      StringBuffer b = new StringBuffer (“B”);
5.     operate (a,b);
6.     system.out.printIn{a + “,” +b};
7. )
8. static void operate (StringBuffer x, StringBuffer y)  {
9.           x.append {y};
10.           y = x;
11.     )
12. }

What is the result?

A. The code compiles and prints “A,B”.
B. The code compiles and prints “A,A”.
C. The code compiles and prints “B,B”.
D. The code compiles and prints “AB,B”.
E. The code compiles and prints “AB,AB”.
F. The code does not compile because “+” cannot be overloaded for StringBuffer.

6. Click the exhibit button:

1. Public class test (
2. Public static void stringReplace (String text)  (
3.      Text = text.replace (‘j’ , ‘i’);
4. )
5. 
6. public static void bufferReplace (StringBuffer text)  (
7.     text = text.append (“C”)
8. )
9. 
10. public static void main (String args[]}  (
11.    String textString = new String (“java”);
12.    StringBuffer text BufferString = new StringBuffer (“java”);
13. 
14.     stringReplace (textString);
15.     BufferReplace (textBuffer);
16. 
17.     System.out.printIn (textString + textBuffer);
18.     }
19.  )

What is the output?
Ans:


7. Click the Exhibit button:

1. public class test {
2.      public static void add3 (Integer i) }
3.      int val = i.intValue ( );
4.           val += 3;
5.           i = new Integer (val);
6.      }
7. 
8.   public static void main (String args [ ] )  {
9.    Integer  i = new Integer (0);
10.     add3 (i);
11.      system.out.printIn (i.intValue ( )  );
12.   }
13. )

What is the result?

A. Compilation will fail.
B. The program prints “0”.
C. The program prints “3”.
D. Compilation will succeed but an exception will be thrown at line 3.

8. Given:

1. public class ConstOver {
2.   public ConstOver (int x, int y, int z)  {
3.      }
4. }

Which two overload the ConstOver constructor? (Choose Two)

A. ConstOver ( ) { }
B. Protected int ConstOver ( ) { }
C. Private ConstOver (int z, int y, byte x) { }
D. public Object ConstOver (int x, int y, int z) { }
E. public void ConstOver (byte x, byte y, byte z) { }

9. Given:

1. public class MethodOver  {
2.     public void setVar (int a, int b, float c)  {
3.     }
4. }

Which two overload the setVar method? (Choose Two)

A. private void setVar (int a, float c, int b)  { }
B. protected void setVar (int a, int b, float c) { }
C. public int setVar (int a, float c, int b) (return a;)
D. public int setVar (int a, int b, float c) (return a;)
E. protected float setVar (int a, int b, float c) (return c;)

10. Given:

1. class BaseClass {
2.    Private float x = 1.0f ;
3.     protected float getVar ( ) ( return x;)
4. }
5. class Subclass extends BaseClass (
6.       private float x = 2.0f;
7.       //insert code here
8. )

Which two are valid examples of method overriding? (Choose Two)

A. float getVar ( ) { return x;}
B. public float getVar ( ) { return x;}
C. float double getVar ( ) { return x;}
D. protected float getVar ( ) { return x;}
E. public float getVar (float f ) { return f;}

11. Which two demonstrate an “is a” relationship? (Choose Two)

A. public interface Person { }
public class Employee extends Person { }
B. public interface Shape { }
public class Employee extends Shape { }
C. public interface Color { }
public class Employee extends Color { }
D. public class Species { }
public class Animal (private Species species;)
E. interface Component { }
Class Container implements Component (
         Private Component[ ] children;
)

12. Which statement is true?

A. An anonymous inner class may be declared as final
B. An anonymous inner class can be declared as private
C. An anonymous inner class can implement multiple interfaces
D. An anonymous inner class can access final variables in any enclosing scope
E. Construction of an instance of a static inner class requires an instance of the
enclosing outer class.

13. Given:

1. package foo;
2. 
3. public class Outer (
4.    public static class Inner (
5.    )
6. )

Which statement is true?

A. An instance of the Inner class can be constructed with “new Outer.Inner ()”
B. An instance of the inner class cannot be constructed outside of package foo
C. An instance of the inner class can only be constructed from within the outer
class
D. From within the package bar, an instance of the inner class can be constructed
with “new inner()”

14. Click the exhibit button:

1. public class enclosingone ( 2. public class insideone{} 3. ) 4. public class
inertest( 5. public static void main (string[]args)( 6. enclosingone eo= new
enclosingone (); 7. //insert code here 8. ) 9. )

Which statement at line 7 constructs an instance of the inner class?

A. InsideOnew ei= eo.new InsideOn();
B. Eo.InsideOne ei = eo.new InsideOne();
C. InsideOne ei = EnclosingOne.new InsideOne();
D. EnclosingOne.InsideOne ei = eo.new InsideOne();

15. Click the exhibit button:

1. interface foo { 2. int k = 0; 3. ] 4.   5. public class test implements Foo ( 6.
public static void main(String args[]) ( 7. int i; 8. Test test = new test (); 9.
i= test.k; 10. i= Test.k; 11. i= Foo.k; 12. ) 13. ) 14.     

What is the result?

A. Compilation succeeds.
B. An error at line 2 causes compilation to fail.
C. An error at line 9 causes compilation to fail.
D. An error at line 10 causes compilation to fail.
E. An error at line 11 causes compilation to fail.

16.  Given:

1. //point X
2. public class foo (
3. public static void main (String[]args) throws Exception {
4. printWriter out = new PrintWriter (new
5. java.io.outputStreamWriter (System.out), true;
6. out.printIn(“Hello”);
7. }
8. )

Which statement at PointX on line 1 allows this code to compile and run?

A. import java.io.PrintWriter;
B. include java.io.PrintWriter;
C. import java.io.OutputStreamWriter;
D. include java.io.OutputStreamWriter;
E. no statement is needed.

======================================================
Connectin cn = DataSource.getConnection();
CallableStatement cstmt = cn.prepareCall("{call myproc ?}");
cstmt.registerOutParameter(1,Types.INTEGER);
cstmt.execute();
cstmt.getInt(1);

create procedure inser_user(@id int out,@name varchar(20),@password varchar(20))
begin transaction
 insert into user(name,password) values(@name,@password);
 select @id=max(id) from user;
commit

Connectin cn = DataSource.getConnection();
CallableStatement cstmt = cn.prepareCall("{call inser_user ?,?,?}");
cstmt.registerOutParameter(1,Types.INTEGER);
cstmt.setParameter(2,'zxx');
cstmt.setParameter(3,'123');
cstmt.execute();
cstmt.getInt(1);

oracle分页
//select rownum from User where rownum<40 and rownum>30
select * from (select * ,rownum as r from user where rownum<41) where r>30
select * from((select * from ((select from User) as u)
 where u.rownum<40) as u2) where u2.rownum>30

sql server分页

(select top 10 * not in (select top 30 from user) from user;

mysql
 select * from user limit 10,10

select top 5 * from sales order by newid()

package abc;

import java.sql.*;

public class H1
{
 public static void main(String[] args) throws Exception
 {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn = DriverManager
   .getConnection("jdbc:oracle:thin:@202.112.85.25:1521:webtest","scott","tiger");
  String procedure = "{ call savedata(?) }";
  CallableStatement cs = conn.prepareCall(procedure);
  cs.setInt(1,100);
  cs.executeUpdate();
  cs.close();
  conn.close();

 }
};

 

create table ht3
(
id int not null primary key,
name varchar(5) not null
);

 

create or replace procedure savedata
(i in number)
as
begin
insert into ht3 values (i,'s' || i);
end;
/


====================================================================
====================================================================
上面的东西很乱吧……确实是,今天由于下午1:20有个面试,所以上午的课没怎么好好听,结果面试的时候没有问
一点和技术有关的问题,结果反倒是我被将了一军。这个面试的是个中年女性,看样子不像是个搞技术的,但是她
也没有对付我,反倒认真的帮我分析了一下我现在心态的问题,确实,这是个值得好好考虑的问题……

事情其实很清楚,只不过我一直不愿意看清楚:甭管什么样子的培训,出来后想3000就业几乎都是不可能的,
除非你包装简历并且谎称自己有1到2年的工作经验,在某某公司做过什么什么项目云云,如果把面试你的人给
骗过去了,再加上你忽悠的本领不错的话,那么月薪3000或是4000多都是可以做到的……听上去挺别扭,但是事实
确实如此,如果你不骗,实话实说,那么你的月薪水平就是2000到2500,没有任何争议,这也是现今社会公认
的程序员的价格尺度……现在的问题就是:我该不该骗……??

下周好像会开始简历的包装工作,通过添加进去一些“项目经验”和“工作经历”来达到最大化未来月薪的目的……
“你认为你真的适合做软件开发工作么,软件开发工作可是很枯燥的……”对于一个前来应聘软件开发工作的没有
工作经验的人说这些话也可以算的上是一种体贴吧,如果是个做技术的面试我他是肯定不会说这些东西的。

“你认为你最喜欢的工作是什么呢?”
这话问的有意思,如果我知道我自己喜欢做什么样的工作,我肯定不会为了这个工作而培训的,有了兴趣基本上
就有了一切,一般来说是这样的……当时我没能回答出来,事后想想,如果这世界上真的有什么职业是我喜欢做的,
那我目前唯一能够想到的就是播音员了,我喜欢照着英文稿子念,而且念个一个小时什么的都不带烦的,
这毛病不知道是什么时候养成的……

“为什么不自学,而选择培训机构呢?”
这话把我恶心坏了,当时语塞,什么都说不出来了……完全是自己的问题,有什么好说的呢,答案明摆着,没有自我
充实,自我学习的动机和心态,缺乏危机意识,竞争意识什么的,独生子女的那些臭毛病尽管往我身上扔好了,扔
多少都能接得住……如果今天我被问到这样的问题还能够理直气壮的给自己找到一个借口的话,那简直是无耻到极点
了(还好我没无耻到那种程度)

“摆正自己的心态,踏实做事,再想到自己待遇的时候先想一想自己能为公司做什么”
这句话可有意思了,今天面试回来大概的和张老师说了一下情况,他也叫我摆正心态,要自信一些,就说自己有
一年工作经验……两边都是摆正心态,但是含义却完全不一样,该选择哪一边呢……?

从那里回来后,3点半方正技术研究院又从班里挑了5个人去笔试,本来是没我什么事的,要不是张老师又把我加上的
话我还真去不了,这真得好好谢谢他,笔试的题目不是很难,东拉西扯的1个小时笔都没停,答完正好也收卷了,不知
最终情况怎么样,这一次我学乖了,在期望月薪那里写了个2400,这应该是没有工作经验又能够胜任一些基本工作的
人的相对来说比较不过分的要价了吧,这么写应该是不得罪人的,就是不知道最后到底会怎么样。一期的李结也是,
在方正这里做完题目后感到容易至极,结果人家最后没有要他,有的时候买方和卖方是很难一致的,同一个事物在不同
人、不同立场看来差别也是很大的。

上面那些杂七杂八的东西是今天两位张老师讲的东西,有一个是讲linux的张老师,据说他在大学的时候曾经是长跑
5000米和10000米的好手,真难以置信啊,看他的样子并不是太外向,虽然和人交流什么的看不出来,但是总觉得
他很内敛,而搞运动的好手一般情况下总让人想到外向……

这个张老师讲课很专业,Oracle、Linux、Java、各种专业工具什么的都玩的相当的熟练,好像是由于自己目前的
企业效益不好所以出来做培训讲师(听说的)……

只是由于太专业,有的时候让人觉得真是有些……跟不上,再加上现在面试笔试什么的,也没什么太多的心情仔细听那些
专用测试工具的具体使用方法了,昨天和今天上午涉及到的那个在线聊天的swing的CS的东西,涉及Socket编程,是
我的绝对弱项中的弱项,得好好看马士兵的教程补一补,所以几乎没有听懂……

=========================================================================================

扯得太远了,其实现在的核心问题是我到底在不在简历上面撒谎……我真的不愿意,因为这并非自己本性,也非自己所愿,
可是如果真的实话实说,那么最后面临的将会是看到周遭人士一个个的3500或是4000的离开,到那时自己还能否保持
心理平衡也是个问题……

所以事情就是这样,你要么就干脆做个从里到外都不在乎撒谎的人,要么就干脆做个本本分分,由里到外都实实在在的、
不在乎别人怎么做的人,就怕你处在中间状态,退也不是,进也不是,高不成、低不就,这就郁闷了……

心理学上这叫做自我之间的冲突,任何心理方面的烦恼、忧虑几乎全是由于人格方面的冲突导致的,你要是有本事把
除了主人格外的其他人格全部杀干净会感到日子轻松不少,其实很多时候并不是外面的东西给了你多大多大的压力,
压力都是由你脑壳中的那滩浆糊造出来的,掌控了那滩浆糊,你就掌控了一切,为什么有的人会信奉宗教或神灵呢?
还是脑壳里面的那滩浆糊搞的,什么时候人类能控制了它、人类也就控制了一切,像什么记忆移植之类的也就不是
梦想了。听起来荒谬,但是值得期待……

思来想去我还是不太想撒谎,确实不太想,那就接受低薪待遇吧,这年头诚实也是有代价的,想在这个充斥了谎言
的社会,这诚实的心态、撒谎就脸红的心态我不知能够保持多久,往好了说这是正直,往不好了说这叫傻、蠢、不懂得
混社会,当很多人凭借着谎言获得很好的待遇的时候,诚信在这个社会也逐渐变得一钱不值,这也就不难理解为什么在
电影“夜宴”中葛优的一句台词“我泱泱大国,诚信为本”能够引发哄堂大笑了……

昨天的程序中还可以考虑添加菜单项,

关键代码(打开文件):

String filePath = "";
    File file = null;
    BufferedReader br;
    String content = "";
   
    public void jMenuItem2_actionPerformed(ActionEvent e) {
        if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
           file = fileChooser.getSelectedFile();
           filePath = file.getAbsolutePath();
           //JOptionPane.showMessageDialog(this,"file:" + filePath);
           try {
             br = new BufferedReader(new FileReader(file));
             content = br.readLine();
             while (content != null){
                 text.append(content + "/n");
                 content = br.readLine();
             }
           }catch(Exception ee){
               ee.printStackTrace();
           }
        
          
        }
    }

 

-----------------------------------------------------------
每个测试方法先调用@Before,然后调用测试方法@Test,再调用@After,
也就是说@Before和@After是每个测试方法都必须调用的!
其实就是那个SetUp和TearDown方法,只不过由于版本的不同导致称呼不同而已……

有一个@BeforeClass只调用一次

一个简单的测试示例如下:

package com.test;

import org.junit.*;
import static org.junit.Assert.*;

public class H1Test
{
 @Before
  public void m1()
 {
  System.out.println("before");
 }

 @Test
  public void t1()
 {
  System.out.println("1");
  assertEquals((1+1),2);
 }

 @Test
  public void t2()
 {
  System.out.println("2");
  assertEquals((1+2),3);
 }

 @After
  public void m2()
 {
  System.out.println("after");
 }

 @BeforeClass
  public static void m3()
  {
   System.out.println("start");
  };

 @AfterClass
  public static void m4()
  {
   System.out.println("stop");
  };

};

///java org.junit.runner.JUnitCore com.test.H1Test
//javac -d .

编译后执行下面的运行命令……
java org.junit.runner.JUnitCore com.test.H1Test


====================================================================

package com.test;

import org.junit.*;
import static org.junit.Assert.*;
import com.web.*;

public class H1Test
{
 H1 h1 = new H1();

 @Before
  public void m1()
 {
  System.out.println("before");
  
 }

 @Test
  public void t1()
 {
  System.out.println("1");
  assertEquals((1+1),2);
 }

 @Test
  public void t2()
 {
  System.out.println("2");
  assertEquals((1+2),3);
 }

 @Test
  public void t3()
 {
  System.out.println("3");
  assertEquals(h1.add(3,4),7);
 }

 @After
  public void m2()
 {
  System.out.println("after");
 }

 @BeforeClass
  public static void m3()
  {
   System.out.println("start");
  };

 @AfterClass
  public static void m4()
  {
   System.out.println("stop");
  };

};

///java org.junit.runner.JUnitCore com.test.H1Test
//javac -d .

td:testdirector Mercury
ibm:rose:cq:clearquest  (测试管理工具:生成测试计划和测试用例)
winrunner:自动化测试(主要用于黑盒测试,也就是功能测试,需要参考需求文档)
loadrunner:负载测试(压力测试):可以产生虚拟用户,比如产生虚拟用户1万人去检测软件

===========================================================================
oracle:
启动:服务器端进程、服务进程
1、启动服务器端进程 oracle sid(不是数据库名)
2、通过客户端进程连接服务器端进程 sqlplus /nolog (不登录:nologin)
3、连接到实例上 set oracle_sid=java (sid)

connect / as sysdba
/:区分用户名和密码:username/password,如果不写代表用户名和密码是任意的

4、启动数据库:startup
startup nomount :只加载实例
startup mount:加载控制文件

5、身份验证:有两种方式
1、通过操作系统身份验证
2、通过数据库验证

connect / as sysdba:通过操作系统验证:在数据库没有打开的时候只能使用这种方式

对登录到操作系统的用户要求必须是属于ora_dba组!
以操作系统身份验证登录映射数据库用户是sys用户

Connection conn = DataSource.getConnection() ;
CallableStatement cstmt = cn.prepareCall("{call insert_user ?,?,?}") ;

cstmt.registerOutParameter(1,Types.INTEGER);//设置输出参数
cstmt.setParameter(2,'zxx');//设置输入参数
cstmt.setParameter(3,'123');
cstmt.execute();
cstmt.getInt(1);//取出了下面存储过程返回的值(也就是刚才插入的用户的id),同时也插入了刚才的用户zxx

//@password和@name是输入参数,@id是输出参数,因为后面有个out!
create procedure insert_user(@id int out,@name varchar(20),@password varchar(20))
begin transaction
 insert into user(name,password) values(@name,@password);
 select @id=max(id) from user ;
commit

-------------------------------------
Oracle分页(第六天里面讲的)
select * from
(
 select last_name,rownum as id from employees
 where rownum<21
)
where id > 11 ;

既然不能够让rownum大于一个具体的非0值,那么先构造一个第一到20个
记录的表,这个表中把rownum的字段抽象成一个别名叫做id
这个id可以作为条件来选择……

这就是分页的解决方法了……在mysql中不支持rownum,所以只有oracle才能
用这种方法分页,mysql中有别的方法来分页!
------------------------------------------------------------------
一个Oracle的存储过程的示例:
package abc;

import java.sql.*;

public class H1
{
 public static void main(String[] args) throws Exception
 {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn = DriverManager
   .getConnection("jdbc:oracle:thin:@202.112.85.25:1521:webtest","scott","tiger");
  String procedure = "{ call savedata(?) }";
  CallableStatement cs = conn.prepareCall(procedure);
  cs.setInt(1,100);
  cs.executeUpdate();
  cs.close();
  conn.close();

 }
};

 

create table ht3
(
id int not null primary key,
name varchar(5) not null
);

 

create or replace procedure savedata
(i in number)
as
begin
insert into ht3 values (i,'s' || i);
end;
/


SQLServer的随机:

select top 5 * from sales order by newid()
//实现随机选5行的方法。
----------------------------------
SQLServer的分页:

select top 3 * from Grade where Player='选手一' and ID not in
        (select top 3 ID from Grade where player='选手一')
===========================================================

1. Given:

1. public class test (
2.   public static void main (String args[])    {
3.       int  i = 0xFFFFFFF1;
4.       int  j = ~i;
5. 
6.      }
7. )

What is the decimal value of j at line 5?

A. 0
B. 1
C. 14
D. -15
E. An error at line 3 causes compilation to fail.
F. An error at line 4 causes compilation to fail.

2. Given:

Integer i = new Integer (42);
Long 1 = new Long (42);
Double d = new Double (42.0);

Which two expressions evaluate to True? (Choose Two)

A. (i ==1)
B. (i == d)
C. (d == 1)
D. (i.equals (d))
E. (d.equals (i))
F. (i.equals (42))

3. Click the exhibit button:

1. public class test (   
2.          private static int j = 0;
3.       
4.        private static boolean methodB(int k) (
5.                j += k;
6.                return true;
7. )
8.
9. public static void methodA(int  i) {
10.          boolean b:  
11.          b = i < 10 | methodB (4);
12.          b = i < 10 || methodB (8);
13. )
14.
15.  public static void main (String args[] }   (
16.              methodA (0);
17.              system.out.printIn(j);
18.            )
19. )

What is the result?

A. The program prints “0”
B. The program prints “4”
C. The program prints “8”
D. The program prints “12”
E. The code does not complete

4. Given:

1.Public class test (
2.    Public static void main (String args[])  (
3.     System.out.printIn (6 ^ 3);
4.   )
5.)

What is the output?

Ans:


5. Given:

1. public class Foo {
2.   public static void main (String [] args)  {
3.      StringBuffer a = new StringBuffer (“A”);
4.      StringBuffer b = new StringBuffer (“B”);
5.     operate (a,b);
6.     system.out.printIn{a + “,” +b};
7. )
8. static void operate (StringBuffer x, StringBuffer y)  {
9.           x.append {y};
10.           y = x;
11.     )
12. }

What is the result?

A. The code compiles and prints “A,B”.
B. The code compiles and prints “A,A”.
C. The code compiles and prints “B,B”.
D. The code compiles and prints “AB,B”.
E. The code compiles and prints “AB,AB”.
F. The code does not compile because “+” cannot be overloaded for StringBuffer.

6. Click the exhibit button:

1. Public class test (
2. Public static void stringReplace (String text)  (
3.      Text = text.replace (‘j’ , ‘i’);
4. )
5. 
6. public static void bufferReplace (StringBuffer text)  (
7.     text = text.append (“C”)
8. )
9. 
10. public static void main (String args[]}  (
11.    String textString = new String (“java”);
12.    StringBuffer text BufferString = new StringBuffer (“java”);
13. 
14.     stringReplace (textString);
15.     BufferReplace (textBuffer);
16. 
17.     System.out.printIn (textString + textBuffer);
18.     }
19.  )

What is the output?
Ans:


7. Click the Exhibit button:

1. public class test {
2.      public static void add3 (Integer i) }
3.      int val = i.intValue ( );
4.           val += 3;
5.           i = new Integer (val);
6.      }
7. 
8.   public static void main (String args [ ] )  {
9.    Integer  i = new Integer (0);
10.     add3 (i);
11.      system.out.printIn (i.intValue ( )  );
12.   }
13. )

What is the result?

A. Compilation will fail.
B. The program prints “0”.
C. The program prints “3”.
D. Compilation will succeed but an exception will be thrown at line 3.

8. Given:

1. public class ConstOver {
2.   public ConstOver (int x, int y, int z)  {
3.      }
4. }

Which two overload the ConstOver constructor? (Choose Two)

A. ConstOver ( ) { }
B. Protected int ConstOver ( ) { }
C. Private ConstOver (int z, int y, byte x) { }
D. public Object ConstOver (int x, int y, int z) { }
E. public void ConstOver (byte x, byte y, byte z) { }

9. Given:

1. public class MethodOver  {
2.     public void setVar (int a, int b, float c)  {
3.     }
4. }

Which two overload the setVar method? (Choose Two)

A. private void setVar (int a, float c, int b)  { }
B. protected void setVar (int a, int b, float c) { }
C. public int setVar (int a, float c, int b) (return a;)
D. public int setVar (int a, int b, float c) (return a;)
E. protected float setVar (int a, int b, float c) (return c;)

10. Given:

1. class BaseClass {
2.    Private float x = 1.0f ;
3.     protected float getVar ( ) ( return x;)
4. }
5. class Subclass extends BaseClass (
6.       private float x = 2.0f;
7.       //insert code here
8. )

Which two are valid examples of method overriding? (Choose Two)

A. float getVar ( ) { return x;}
B. public float getVar ( ) { return x;}
C. float double getVar ( ) { return x;}
D. protected float getVar ( ) { return x;}
E. public float getVar (float f ) { return f;}

11. Which two demonstrate an “is a” relationship? (Choose Two)

A. public interface Person { }
public class Employee extends Person { }
B. public interface Shape { }
public class Employee extends Shape { }
C. public interface Color { }
public class Employee extends Color { }
D. public class Species { }
public class Animal (private Species species;)
E. interface Component { }
Class Container implements Component (
         Private Component[ ] children;
)

12. Which statement is true?

A. An anonymous inner class may be declared as final
B. An anonymous inner class can be declared as private
C. An anonymous inner class can implement multiple interfaces
D. An anonymous inner class can access final variables in any enclosing scope
E. Construction of an instance of a static inner class requires an instance of the
enclosing outer class.

13. Given:

1. package foo;
2. 
3. public class Outer (
4.    public static class Inner (
5.    )
6. )

Which statement is true?

A. An instance of the Inner class can be constructed with “new Outer.Inner ()”
B. An instance of the inner class cannot be constructed outside of package foo
C. An instance of the inner class can only be constructed from within the outer
class
D. From within the package bar, an instance of the inner class can be constructed
with “new inner()”

14. Click the exhibit button:

1. public class enclosingone ( 2. public class insideone{} 3. ) 4. public class
inertest( 5. public static void main (string[]args)( 6. enclosingone eo= new
enclosingone (); 7. //insert code here 8. ) 9. )

Which statement at line 7 constructs an instance of the inner class?

A. InsideOnew ei= eo.new InsideOn();
B. Eo.InsideOne ei = eo.new InsideOne();
C. InsideOne ei = EnclosingOne.new InsideOne();
D. EnclosingOne.InsideOne ei = eo.new InsideOne();

15. Click the exhibit button:

1. interface foo { 2. int k = 0; 3. ] 4.   5. public class test implements Foo ( 6.
public static void main(String args[]) ( 7. int i; 8. Test test = new test (); 9.
i= test.k; 10. i= Test.k; 11. i= Foo.k; 12. ) 13. ) 14.     

What is the result?

A. Compilation succeeds.
B. An error at line 2 causes compilation to fail.
C. An error at line 9 causes compilation to fail.
D. An error at line 10 causes compilation to fail.
E. An error at line 11 causes compilation to fail.

16.  Given:

1. //point X
2. public class foo (
3. public static void main (String[]args) throws Exception {
4. printWriter out = new PrintWriter (new
5. java.io.outputStreamWriter (System.out), true;
6. out.printIn(“Hello”);
7. }
8. )

Which statement at PointX on line 1 allows this code to compile and run?

A. import java.io.PrintWriter;
B. include java.io.PrintWriter;
C. import java.io.OutputStreamWriter;
D. include java.io.OutputStreamWriter;
E. no statement is needed.

======================================================
Connectin cn = DataSource.getConnection();
CallableStatement cstmt = cn.prepareCall("{call myproc ?}");
cstmt.registerOutParameter(1,Types.INTEGER);
cstmt.execute();
cstmt.getInt(1);

create procedure inser_user(@id int out,@name varchar(20),@password varchar(20))
begin transaction
 insert into user(name,password) values(@name,@password);
 select @id=max(id) from user;
commit

Connectin cn = DataSource.getConnection();
CallableStatement cstmt = cn.prepareCall("{call inser_user ?,?,?}");
cstmt.registerOutParameter(1,Types.INTEGER);
cstmt.setParameter(2,'zxx');
cstmt.setParameter(3,'123');
cstmt.execute();
cstmt.getInt(1);

oracle分页
//select rownum from User where rownum<40 and rownum>30
select * from (select * ,rownum as r from user where rownum<41) where r>30
select * from((select * from ((select from User) as u)
 where u.rownum<40) as u2) where u2.rownum>30

sql server分页

(select top 10 * not in (select top 30 from user) from user;

mysql
 select * from user limit 10,10

select top 5 * from sales order by newid()

package abc;

import java.sql.*;

public class H1
{
 public static void main(String[] args) throws Exception
 {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn = DriverManager
   .getConnection("jdbc:oracle:thin:@202.112.85.25:1521:webtest","scott","tiger");
  String procedure = "{ call savedata(?) }";
  CallableStatement cs = conn.prepareCall(procedure);
  cs.setInt(1,100);
  cs.executeUpdate();
  cs.close();
  conn.close();

 }
};

 

create table ht3
(
id int not null primary key,
name varchar(5) not null
);

 

create or replace procedure savedata
(i in number)
as
begin
insert into ht3 values (i,'s' || i);
end;
/


====================================================================
====================================================================
上面的东西很乱吧……确实是,今天由于下午1:20有个面试,所以上午的课没怎么好好听,结果面试的时候没有问
一点和技术有关的问题,结果反倒是我被将了一军。这个面试的是个中年女性,看样子不像是个搞技术的,但是她
也没有对付我,反倒认真的帮我分析了一下我现在心态的问题,确实,这是个值得好好考虑的问题……

事情其实很清楚,只不过我一直不愿意看清楚:甭管什么样子的培训,出来后想3000就业几乎都是不可能的,
除非你包装简历并且谎称自己有1到2年的工作经验,在某某公司做过什么什么项目云云,如果把面试你的人给
骗过去了,再加上你忽悠的本领不错的话,那么月薪3000或是4000多都是可以做到的……听上去挺别扭,但是事实
确实如此,如果你不骗,实话实说,那么你的月薪水平就是2000到2500,没有任何争议,这也是现今社会公认
的程序员的价格尺度……现在的问题就是:我该不该骗……??

下周好像会开始简历的包装工作,通过添加进去一些“项目经验”和“工作经历”来达到最大化未来月薪的目的……
“你认为你真的适合做软件开发工作么,软件开发工作可是很枯燥的……”对于一个前来应聘软件开发工作的没有
工作经验的人说这些话也可以算的上是一种体贴吧,如果是个做技术的面试我他是肯定不会说这些东西的。

“你认为你最喜欢的工作是什么呢?”
这话问的有意思,如果我知道我自己喜欢做什么样的工作,我肯定不会为了这个工作而培训的,有了兴趣基本上
就有了一切,一般来说是这样的……当时我没能回答出来,事后想想,如果这世界上真的有什么职业是我喜欢做的,
那我目前唯一能够想到的就是播音员了,我喜欢照着英文稿子念,而且念个一个小时什么的都不带烦的,
这毛病不知道是什么时候养成的……

“为什么不自学,而选择培训机构呢?”
这话把我恶心坏了,当时语塞,什么都说不出来了……完全是自己的问题,有什么好说的呢,答案明摆着,没有自我
充实,自我学习的动机和心态,缺乏危机意识,竞争意识什么的,独生子女的那些臭毛病尽管往我身上扔好了,扔
多少都能接得住……如果今天我被问到这样的问题还能够理直气壮的给自己找到一个借口的话,那简直是无耻到极点
了(还好我没无耻到那种程度)

“摆正自己的心态,踏实做事,再想到自己待遇的时候先想一想自己能为公司做什么”
这句话可有意思了,今天面试回来大概的和张老师说了一下情况,他也叫我摆正心态,要自信一些,就说自己有
一年工作经验……两边都是摆正心态,但是含义却完全不一样,该选择哪一边呢……?

从那里回来后,3点半方正技术研究院又从班里挑了5个人去笔试,本来是没我什么事的,要不是张老师又把我加上的
话我还真去不了,这真得好好谢谢他,笔试的题目不是很难,东拉西扯的1个小时笔都没停,答完正好也收卷了,不知
最终情况怎么样,这一次我学乖了,在期望月薪那里写了个2400,这应该是没有工作经验又能够胜任一些基本工作的
人的相对来说比较不过分的要价了吧,这么写应该是不得罪人的,就是不知道最后到底会怎么样。一期的李结也是,
在方正这里做完题目后感到容易至极,结果人家最后没有要他,有的时候买方和卖方是很难一致的,同一个事物在不同
人、不同立场看来差别也是很大的。

上面那些杂七杂八的东西是今天两位张老师讲的东西,有一个是讲linux的张老师,据说他在大学的时候曾经是长跑
5000米和10000米的好手,真难以置信啊,看他的样子并不是太外向,虽然和人交流什么的看不出来,但是总觉得
他很内敛,而搞运动的好手一般情况下总让人想到外向……

这个张老师讲课很专业,Oracle、Linux、Java、各种专业工具什么的都玩的相当的熟练,好像是由于自己目前的
企业效益不好所以出来做培训讲师(听说的)……

只是由于太专业,有的时候让人觉得真是有些……跟不上,再加上现在面试笔试什么的,也没什么太多的心情仔细听那些
专用测试工具的具体使用方法了,昨天和今天上午涉及到的那个在线聊天的swing的CS的东西,涉及Socket编程,是
我的绝对弱项中的弱项,得好好看马士兵的教程补一补,所以几乎没有听懂……

=========================================================================================

扯得太远了,其实现在的核心问题是我到底在不在简历上面撒谎……我真的不愿意,因为这并非自己本性,也非自己所愿,
可是如果真的实话实说,那么最后面临的将会是看到周遭人士一个个的3500或是4000的离开,到那时自己还能否保持
心理平衡也是个问题……

所以事情就是这样,你要么就干脆做个从里到外都不在乎撒谎的人,要么就干脆做个本本分分,由里到外都实实在在的、
不在乎别人怎么做的人,就怕你处在中间状态,退也不是,进也不是,高不成、低不就,这就郁闷了……

心理学上这叫做自我之间的冲突,任何心理方面的烦恼、忧虑几乎全是由于人格方面的冲突导致的,你要是有本事把
除了主人格外的其他人格全部杀干净会感到日子轻松不少,其实很多时候并不是外面的东西给了你多大多大的压力,
压力都是由你脑壳中的那滩浆糊造出来的,掌控了那滩浆糊,你就掌控了一切,为什么有的人会信奉宗教或神灵呢?
还是脑壳里面的那滩浆糊搞的,什么时候人类能控制了它、人类也就控制了一切,像什么记忆移植之类的也就不是
梦想了。听起来荒谬,但是值得期待……

思来想去我还是不太想撒谎,确实不太想,那就接受低薪待遇吧,这年头诚实也是有代价的,想在这个充斥了谎言
的社会,这诚实的心态、撒谎就脸红的心态我不知能够保持多久,往好了说这是正直,往不好了说这叫傻、蠢、不懂得
混社会,当很多人凭借着谎言获得很好的待遇的时候,诚信在这个社会也逐渐变得一钱不值,这也就不难理解为什么在
电影“夜宴”中葛优的一句台词“我泱泱大国,诚信为本”能够引发哄堂大笑了……

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值