I use eclipse configure hibernate tools installed the wrong end of the time .
------ Solution ------- -------------------------------------
it will only start again the
------ For reference only ---------------------------------------
previously downloaded version is 4.0 , eclipse plug-in a variety of installation methods will not work.
finally see a bit of their own eclipse version 4.2.0 found
then download the 3.3 version of the decisive so that the.
------ For reference only -------------------------------------- -
Only you a reply , points will give you.
2013年9月28日星期六
SQL talk : count (1) and count (*)
This post last edited by the xj90314 on 2012-11-28 09:53:46
everyone in the program when the total number of more or less will encounter statistics sql, then . We count this function is frequently used it. ago I remember reading a post that , count (1) than the count (*) fast, the reason is simple . I am only the first column statistics. Saying in theory, should be right. But the reality is not the case .
Let me give an example , my own writing sql. to data confidentiality , I changed the name of the table , you will forgive me .
select
--*
count(1)
from tt where change_date>='2012-05-28' and change_date<='2012-08-28'
Data volume: 28,753
The result is : 1 row selected in 0.26 secs.
second SQL
select
--*
count(*)
from tt where change_date>='2012-05-28' and change_date<='2012-08-28'
Data volume: 28,753
The result is : 1 row selected in 0.25 secs.
count (*) than the count (1) fast 0.01secs.
Well, I try to increase the amount of data . Time raised the year before.
sql:
select
--*
count(*)
from tt where change_date>='2011-05-28' and change_date<='2012-08-28'
Data volume: 82,805
Time Results : 1 row selected in 0.31 secs.
sql:
select
--*
count(1)
from tt where change_date>='2011-05-28' and change_date<='2012-08-28'
Data volume: 82,805
Time : 1 row selected in 0.26 secs.
It seems when a large quantity of data count (1) performance will be a good point , well, continue to increase the amount of data
SQL:
select
--*
count(1)
from tt
The result: 243,511
Time : 1 row selected in 2.20 secs.
select
--*
count(*)
from tt
The result: 243,511
Time : 1 row selected in 0.12 secs.
MB, the evil it. . . . I test environment : VM4xp db2
welcome everyone refers to three four .
------ Solution - -------------------------------------------
1, saying that forum posts should go to the database made ;
2, different databases and different versions of different results ;
3, in fact, a lot of knowledge is constantly updated , and now most of the databases are already count (*) is optimized , so unless it is antique , otherwise basically direct count (*).
------ Solution ---------------------------------------- ----
really quickly · · ·
------ Solution ------------------------ --------------------
like Mice said , count (*) have been optimized !
count (*) time, if the table has PK, then take the PK, PK to find not null no index !
count (1) If you are one of the field has an index then take the index , PK left PK, if not , it can not speed up !
------ Solution ---------------------------------------- ----
count (*)
count (1)
count ( field )
There should be three , meaning I have already made it very clear , I will not say more
------ Solution --------------- -----------------------------
theoretically , count (*) statistical results of rows and multiple columns single row the number of rows , the result is the same , it must be selected in the realization of a simple way .
------ For reference only -------------------------------------- -
share your couch really fast . .
------ For reference only -------------------------------------- -
Today, just open CSDN, see the first post is for you. . .
------ For reference only -------------------------------------- -
not send execution plan what use is made of time .
even where conditions are not the same as the SQL you feel that you just change the amount of data ?
write directly count (*) If you take the index , simply do not take the table .
------ For reference only -------------------------------------- -
brother, how where it is not the same ? I said that is not clear or you can not bear to look carefully I write sql
------ For reference only ---------------------------------------
I do not have the heart to ask your primary language teacher of the current situation .
select
- *
count (*)
from tt where change_date> = '2012-05-28 'and change_date <= '2012-08-28'
select
- *
count (1)
from tt where change_date> = '2012-05-28 'and change_date <= '2012-08-28'
Do you think the database less count (1) fast , right ?
where conditions and then a change of the number of multi-point , do you think count (*) Get up , eh ?
Then you feel select count (1) from tt point this thing increase the amount of data , count (*) should be faster , it's not what you say it ?
did this thing where the conditions , and in front of you have anything ?
To compare you have to compare is select count (1) from tt where change_date> = '1900-01-01 'and change_date <= '3999-01-01'
------ For reference only ---------------------------------- -----
landlord , this error estimates are within the scope of any statement execution
Also a sql, execute n times, the time between each error range .
------ For reference only ---------------------------------- -----
brother, you see Haha, I speak only for data , the speed did not say anything , says
------ For reference only --- ------------------------------------
I did not publish any of my conclusions. . .
------ For reference only -------------------------------------- -
ah , that you think that the result is normal , is that you in the evil , not the database evil , right .
That I did not watch carefully .
------ For reference only -------------------------------------- -
select (1) faster , and I was using select (1), because the project is written like this , with everyone , or else select (*) did not level
------ for reference only ---------------------------------------
for most commercial data speaking
with a primary key or index , count (*) faster
these databases , count (1) is not to use the index , while the count (*) will automatically scan the column index ( primary key or index )
database or some files may not have this small database optimization strategies
------ For reference only ---------------------- -----------------
've always heard people say to use count (*) said
------ For reference only ----- ----------------------------------
this is what you said in the antique and of the ...
------ For reference only --------------------------------- ------
learning can not be blind , who are required to do dialectical thinking .
support the landlord issues of this right to test and share test results with a good attitude and practices.
contempt hearsay convinced, and some even show off yet unassuming man.
The above represents only personal views .
ps: I usually have all count (*), because I found in my database * or one or both fields, query plans are the same ...
------ For reference only ---------------------------------- -----
upstairs well said ! count (0) count (1) count (*) which in the end what is the difference ah , all of them were under what conditions to use ah ?
Java way to post a request on the https protocol site issues
Request online to find a variety of ways https protocol , almost all the following forms:
However, I used this method to access it , or not being given :
[16:38:19.303] java.lang.IllegalArgumentException: protocol = https host = null
Which god , there is wood there a good way ah.
------ Solution ------------------------------------ --------
try SSLContext sc = SSLContext.getInstance ("SSL", "SunJSSE");
------ For reference only - -------------------------------------
or not , the same error
- ----- For reference only ---------------------------------------
which line newspaper 's fault ?
------ For reference only -------------------------------------- -
reported that this line conn.connect ();
------ For reference only --------------------- ------------------
this is the wrong message
------ For reference only ----- ----------------------------------
commented conn.setHostnameVerifier (new TrustAnyHostnameVerifier ()); try
------ For reference only ------------------------------------ ---
commented , still the same error what method you use to access the https ?
------ For reference only -------------------------------------- -
requested address was wrong , https ; less behind both slash. . . Plus after it. . . Own imprudent . .
public class HttpsUtil{
private static class TrustAnyTrustManager implements X509TrustManager {
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[] {};
}
}
private static class TrustAnyHostnameVerifier implements HostnameVerifier {
public boolean verify(String hostname, SSLSession session) {
return true;
}
}
/**
* post方式请求服务器(https协议)
* @param url
* 请求地址
* @param content
* 参数
* @param charset
* 编码
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
* @throws IOException
*/
public static byte[] post(String url, String content, String charset)
throws NoSuchAlgorithmException, KeyManagementException,
IOException {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, new TrustManager[] { new TrustAnyTrustManager() },
new java.security.SecureRandom());
URL console = new URL(url);
HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
conn.setSSLSocketFactory(sc.getSocketFactory());
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
conn.connect();
DataOutputStream out = new DataOutputStream(conn.getOutputStream());
out.write(content.getBytes(charset));
// 刷新、关闭
out.flush();
out.close();
InputStream is = conn.getInputStream();
if (is != null) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = is.read(buffer)) != -1) {
outStream.write(buffer, 0, len);
}
is.close();
return outStream.toByteArray();
}
return null;
}
}
However, I used this method to access it , or not being given :
[16:38:19.303] java.lang.IllegalArgumentException: protocol = https host = null
Which god , there is wood there a good way ah.
------ Solution ------------------------------------ --------
try SSLContext sc = SSLContext.getInstance ("SSL", "SunJSSE");
------ For reference only - -------------------------------------
or not , the same error
- ----- For reference only ---------------------------------------
which line newspaper 's fault ?
------ For reference only -------------------------------------- -
reported that this line conn.connect ();
------ For reference only --------------------- ------------------
this is the wrong message
------ For reference only ----- ----------------------------------
commented conn.setHostnameVerifier (new TrustAnyHostnameVerifier ()); try
------ For reference only ------------------------------------ ---
commented , still the same error what method you use to access the https ?
------ For reference only -------------------------------------- -
requested address was wrong , https ; less behind both slash. . . Plus after it. . . Own imprudent . .
A small program output questions
Just learning JAVA, the first question is to determine whether the input is a leap year , as follows:
package experimental one ;
import java.io.IOException;
public class Year {
/ ** use if ... else statement to construct multi-branch , to determine whether a particular year is a leap year . Leap year is in line with the conditions under
face either: divisible by 4 but not divisible by 100 ; evenly divisible by four , but also divisible by 400 ** /
public static void main (String [] args) throws IOException {
/ / byte [] b = new byte [1000];
/ / int y = System.in.read (b);
int y = System.in.read ();
int a = y% 4;
int c = y% 100;
int d = y% 400;
if (a == 0 && c! = 0 | | d == 0)
{
System.out.println (y + " is a leap year " ) ;
}
else
{
System.out.println (y + " not a leap year " ) ;
}
}
}
Enter "2000" after the output is " 50 years is not a leap year ." I do not know what went wrong , why is there a "50" of the
------ Solution ------------------------------------ --------
int y = System.in.read (); this is a problem, go see Inputstream read method API
------ Solution ---- ----------------------------------------
I have just less than a self- weeks. LZ write a good feeling trouble .
This is my own writing , no other meaning .
import java.util. *;
public class lianxi {
public static void main (String [] args) {
Scanner input = new Scanner (System.in);
System.out.println (" Please enter a year: " ) ;
int year = input.nextInt ();
if (year% 4 == 0 && year% 100! = 0) {
System.out.println ();
} else if (year% 400 == 0) {
System.out.println (year + " is a leap year " ) ;
}
}
}
------ Solution ----------------------------------- ---------
------ For reference only -------------------------------------- -
public abstract int read () throws IOException
from the input stream to read the next data byte. Return within the range 0-255 int byte value. If the end of the stream has been reached because no byte is available , the return value is -1 . In the input data is available, the end of the stream is detected , or an exception is thrown , this method has been blocked.
Returns:
next data byte, if the end of the stream is reached , -1 is returned.
------ For reference only ---------------------------------- -----
Thank you parents learned a reply ~ ~ ~
has been run successfully
package experimental one ;
import java.io.IOException;
public class Year {
/ ** use if ... else statement to construct multi-branch , to determine whether a particular year is a leap year . Leap year is in line with the conditions under
face either: divisible by 4 but not divisible by 100 ; evenly divisible by four , but also divisible by 400 ** /
public static void main (String [] args) throws IOException {
/ / byte [] b = new byte [1000];
/ / int y = System.in.read (b);
int y = System.in.read ();
int a = y% 4;
int c = y% 100;
int d = y% 400;
if (a == 0 && c! = 0 | | d == 0)
{
System.out.println (y + " is a leap year " ) ;
}
else
{
System.out.println (y + " not a leap year " ) ;
}
}
}
Enter "2000" after the output is " 50 years is not a leap year ." I do not know what went wrong , why is there a "50" of the
------ Solution ------------------------------------ --------
int y = System.in.read (); this is a problem, go see Inputstream read method API
------ Solution ---- ----------------------------------------
I have just less than a self- weeks. LZ write a good feeling trouble .
This is my own writing , no other meaning .
import java.util. *;
public class lianxi {
public static void main (String [] args) {
Scanner input = new Scanner (System.in);
System.out.println (" Please enter a year: " ) ;
int year = input.nextInt ();
if (year% 4 == 0 && year% 100! = 0) {
System.out.println ();
} else if (year% 400 == 0) {
System.out.println (year + " is a leap year " ) ;
}
}
}
------ Solution ----------------------------------- ---------
import java.util.Scanner;Proposed landlord wrote , enter 2000 for 50 shows this problem is System.in.read () this method caused . read () method to read a character that you enter 2000 , he only read the first one that is '2 ' this character , and this character through the ASC code will turn into an int by ASC code table query '2' the ASC code is 50 characters , so the show is 50 , it is recommended that way with my landlord to get the terminal parameters.
public class Runnian{
public static void main(String[] args) throws Exception{
Scanner scanner = new Scanner(System.in);
int year = scanner.nextInt();
int a = year%4;
int b = year%400;
int c = year%100;
if(a==0 && c!=0){
System.out.println(year+"is Runnian!");
}else if(a==0 && b==0){
System.out.println(year+"is Runnian!");
}else{
System.out.println(year+"is not Runnian!");
}
}
}
------ For reference only -------------------------------------- -
public abstract int read () throws IOException
from the input stream to read the next data byte. Return within the range 0-255 int byte value. If the end of the stream has been reached because no byte is available , the return value is -1 . In the input data is available, the end of the stream is detected , or an exception is thrown , this method has been blocked.
Returns:
next data byte, if the end of the stream is reached , -1 is returned.
------ For reference only ---------------------------------- -----
Thank you parents learned a reply ~ ~ ~
has been run successfully