问:
Flink Streamer in Apache Ignite
I am working on real time streaming data analysis using Apache Flink-1.1.3. My system consist of Kafka cluster for message queue, Flink cluster which read the messages from kafka partitions and make some analysis on it and finally I want to dump the generated data into Ignite Cache. For the system I am using IgniteSink class to sink the data into ignite cache. The versions are as follows:

Flink 1.1.3,

Kafka 2.10,
Ignite 2.0.0

When I tried to run the job on flink cluster it gives me the following error,

```<code>Exception in thread "main" org.apache.flink.client.program.ProgramInvocationException: The program execution failed: Job execution failed.
at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:409)
at org.apache.flink.client.program.StandaloneClusterClient.submitJob(StandaloneClusterClient.java:95)
at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:382)
at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:374)
at org.apache.flink.streaming.api.environment.RemoteStreamEnvironment.executeRemotely(RemoteStreamEnvironment.java:209)
at org.apache.flink.streaming.api.environment.RemoteStreamEnvironment.execute(RemoteStreamEnvironment.java:173)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1429)
at flink_ignite_sink_remote.main(flink_ignite_sink_remote.java:77)
Caused by: org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
at org.apache.flink.runtime.jobmanager.JobManager$$anonfun$handleMessage$1$$anonfun$applyOrElse$8.apply$mcV$sp(JobManager.scala:822)
at org.apache.flink.runtime.jobmanager.JobManager$$anonfun$handleMessage$1$$anonfun$applyOrElse$8.apply(JobManager.scala:768)
at org.apache.flink.runtime.jobmanager.JobManager$$anonfun$handleMessage$1$$anonfun$applyOrElse$8.apply(JobManager.scala:768)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:41)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:401)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.ignite.sink.flink.IgniteSink$SinkContext$Holder
at org.apache.ignite.sink.flink.IgniteSink$SinkContext.getStreamer(IgniteSink.java:201)
at org.apache.ignite.sink.flink.IgniteSink$SinkContext.access$100(IgniteSink.java:175)
at org.apache.ignite.sink.flink.IgniteSink.invoke(IgniteSink.java:165)
at org.apache.flink.streaming.api.operators.StreamSink.processElement(StreamSink.java:39)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:373)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:358)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:346)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:329)
at org.apache.flink.streaming.api.operators.TimestampedCollector.collect(TimestampedCollector.java:51)
at flink_ignite_sink_remote$Splitter.flatMap(flink_ignite_sink_remote.java:177)
at flink_ignite_sink_remote$Splitter.flatMap(flink_ignite_sink_remote.java:1)
at org.apache.flink.streaming.api.operators.StreamFlatMap.processElement(StreamFlatMap.java:48)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:373)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:358)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:346)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:329)
at org.apache.flink.streaming.api.operators.StreamSource$NonTimestampContext.collect(StreamSource.java:161)
at org.apache.flink.streaming.connectors.kafka.internals.AbstractFetcher.emitRecord(AbstractFetcher.java:225)
at org.apache.flink.streaming.connectors.kafka.internal.Kafka09Fetcher.run(Kafka09Fetcher.java:253)
at java.lang.Thread.run(Thread.java:745)
</code>```

I have included all the libraries of Ignite-Flink into my project, still I got java.lang.NoClassDefFoundError error.

答:
When you work with flink jobs, that you deploy over a flink cluster, you have 2 options:

Generate a jar file with all your dependencies bundled inside and deploy that jar

Add all your dependencies to the classpath of your flink server, so it can find those dependencies out of the jar file.

You problem looks like you are not generating a jar file with all the dependencies inside of it and those dependencies aren't located inside the classpath of the fink server.

Try running the following mvn command to generate your jars:

mvn clean package -Pbuild-jar

It could generate multiple jar, pick the fat jar (the bigger)

Title: Flink Streamer in Apache Ignite

Body:
I am working on real time streaming data analysis using Apache Flink-1.1.3. My system consist of Kafka cluster for message queue, Flink cluster which read the messages from kafka partitions and make some analysis on it and finally I want to dump the generated data into Ignite Cache. For the system I am using IgniteSink class to sink the data into ignite cache. The versions are as follows:

Flink 1.1.3,

Kafka 2.10,
Ignite 2.0.0

When I tried to run the job on flink cluster it gives me the following error,

Exception in thread "main" org.apache.flink.client.program.ProgramInvocationException: The program execution failed: Job execution failed.
at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:409)
at org.apache.flink.client.program.StandaloneClusterClient.submitJob(StandaloneClusterClient.java:95)
at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:382)
at org.apache.flink.client.program.ClusterClient.run(ClusterClient.java:374)
at org.apache.flink.streaming.api.environment.RemoteStreamEnvironment.executeRemotely(RemoteStreamEnvironment.java:209)
at org.apache.flink.streaming.api.environment.RemoteStreamEnvironment.execute(RemoteStreamEnvironment.java:173)
at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.execute(StreamExecutionEnvironment.java:1429)
at flink_ignite_sink_remote.main(flink_ignite_sink_remote.java:77)
Caused by: org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
at org.apache.flink.runtime.jobmanager.JobManager$$anonfun$handleMessage$1$$anonfun$applyOrElse$8.apply$mcV$sp(JobManager.scala:822)
at org.apache.flink.runtime.jobmanager.JobManager$$anonfun$handleMessage$1$$anonfun$applyOrElse$8.apply(JobManager.scala:768)
at org.apache.flink.runtime.jobmanager.JobManager$$anonfun$handleMessage$1$$anonfun$applyOrElse$8.apply(JobManager.scala:768)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:41)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:401)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.ignite.sink.flink.IgniteSink$SinkContext$Holder
at org.apache.ignite.sink.flink.IgniteSink$SinkContext.getStreamer(IgniteSink.java:201)
at org.apache.ignite.sink.flink.IgniteSink$SinkContext.access$100(IgniteSink.java:175)
at org.apache.ignite.sink.flink.IgniteSink.invoke(IgniteSink.java:165)
at org.apache.flink.streaming.api.operators.StreamSink.processElement(StreamSink.java:39)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:373)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:358)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:346)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:329)
at org.apache.flink.streaming.api.operators.TimestampedCollector.collect(TimestampedCollector.java:51)
at flink_ignite_sink_remote$Splitter.flatMap(flink_ignite_sink_remote.java:177)
at flink_ignite_sink_remote$Splitter.flatMap(flink_ignite_sink_remote.java:1)
at org.apache.flink.streaming.api.operators.StreamFlatMap.processElement(StreamFlatMap.java:48)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:373)
at org.apache.flink.streaming.runtime.tasks.OperatorChain$CopyingChainingOutput.collect(OperatorChain.java:358)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:346)
at org.apache.flink.streaming.api.operators.AbstractStreamOperator$CountingOutput.collect(AbstractStreamOperator.java:329)
at org.apache.flink.streaming.api.operators.StreamSource$NonTimestampContext.collect(StreamSource.java:161)
at org.apache.flink.streaming.connectors.kafka.internals.AbstractFetcher.emitRecord(AbstractFetcher.java:225)
at org.apache.flink.streaming.connectors.kafka.internal.Kafka09Fetcher.run(Kafka09Fetcher.java:253)
at java.lang.Thread.run(Thread.java:745)

I have included all the libraries of Ignite-Flink into my project, still I got java.lang.NoClassDefFoundError error.


来源: stackexchange

问:
windows cmd for loop cycle and time counting + percentage
First i was looking for a code if already exist here or elsewhere,
but found no result with my requirements.
So i started to build it up part by part.
I set few things like getting total number,
than create temp file if not exist.
If file with the record exist than set record of how much is done
,after put that in a loop cycle "for"
and count everything to show results also with the percentage.

So this is actually the result of what i have done.

```<code>@echo off
setlocal enableExtensions enableDelayedExpansion
set /p NUMBER=<total_number.info
set INFO_FILE=total_done.info
IF NOT EXIST %INFO_FILE% (
    (echo 1) > %INFO_FILE%
)
set /p NUMBER_DONE=<%INFO_FILE%
for /l %%x in (%NUMBER_DONE%, 1, %NUMBER%) do (
    set /a "Total_Left=%NUMBER%-%%x"
    set /a "percent=(%%x*100)/%NUMBER%"
    if !Total_Left! GEQ 1 (
        set /a "Seconds=!Total_Left!*2"
    ) else (
        set /a "Seconds=00"
    )
    if !Seconds! GEQ 60 (
        set /a "Minutes=!Seconds!/60"
    ) else (
        set /a "Minutes=00"
    )
    if !Minutes! GEQ 60 (
        set /a "Hours=!Minutes!/60"
    ) else (
        set /a "Hours=00"
    )
    if !Hours! GEQ 24 (
        set /a "Days=!Hours!/24"
    ) else (
        set /a "Days=0"
    )
    set /a "T_L_H=!Hours!-(!Days!*24)"
    set /a "T_L_M=!Minutes!-(!Hours!*60)"
    set /a "T_L_S=!Seconds!-(!Minutes!*60)"
    set "T_L_Ho=0!T_L_H!"
    set "T_L_Mi=0!T_L_M!"
    set "T_L_Se=0!T_L_S!"
    TITLE Test - Percent done : !percent!%%
    echo.
    echo Time Left : !Days! Days !T_L_Ho:~-2!:!T_L_Mi:~-2!:!T_L_Se:~-2!
    echo.
    echo Total pages to be done : %NUMBER%
    echo Pages done : %%x
    echo Rest of the pages : !Total_Left!
    echo Percent done : !percent!%%
    if %%x GEQ %NUMBER_DONE% (
        (echo %%x) > %INFO_FILE%
        timeout 1 > NUL
    )
    cls
)
pause>NUL
</code>```

Script last time updated 12.1.2018 23:45

答:
Here is a PowerShell script that will monitor progress using a file containing the current step number. Be sure to create the watch file before starting it.

```<code><#
.SYNOPSIS
This cmdlet displays a progress bar based on monitoring a watch file.

.DESCRIPTION
If no PROMPT string is provided, the $Env:PROMPT string will be used.

.PARAMETER TotalCount
Specify the total number of steps to monitor.

.PARAMETER WatchFile
Specify the path to the file containing the number of steps completed.

.EXAMPLE
Monitor-Progress -TotalCount 10 -WatchFile wf.txt
#>
[CmdletBinding()]
Param (
    [Parameter(Mandatory=$true)]
    [int]$TotalCount

    ,[Parameter(Mandatory=$true)]
    [ValidateScript({Test-Path $_ -PathType 'Leaf'})]
    [string]$WatchFile
)

$currentcount = 0
$previouscount = $currentcount

while ($currentcount -lt $TotalCount) {
    $currentcount = [int32](Get-Content $WatchFile)

    if ($currentcount -ne $previouscount) {
        Write-Progress -Activity "Watching long progress" `
            -percentComplete ($currentcount / $TotalCount*100)
        $previouscount = $currentcount
    }
}
</code>```

If you need to run this from the cmd.exe shell, you can:

```<code>powershell -NoProfile -File Monitor-Progress.ps1 -TotalCount 5 -WatchFile wf.txt
</code>```

ContentLicense: CC BY-SA 3.0

Body:
First i was looking for a code if already exist here or elsewhere,
but found no result with my requirements.
So i started to build it up part by part.
I set few things like getting total number,
than create temp file if not exist.
If file with the record exist than set record of how much is done
,after put that in a loop cycle "for"
and count everything to show results also with the percentage.

So this is actually the result of what i have done.

@echo off
setlocal enableExtensions enableDelayedExpansion
set /p NUMBER=<total_number.info
set INFO_FILE=total_done.info
IF NOT EXIST %INFO_FILE% (
    (echo 1) > %INFO_FILE%
)
set /p NUMBER_DONE=<%INFO_FILE%
for /l %%x in (%NUMBER_DONE%, 1, %NUMBER%) do (
    set /a "Total_Left=%NUMBER%-%%x"
    set /a "percent=(%%x*100)/%NUMBER%"
    if !Total_Left! GEQ 1 (
        set /a "Seconds=!Total_Left!*2"
    ) else (
        set /a "Seconds=00"
    )
    if !Seconds! GEQ 60 (
        set /a "Minutes=!Seconds!/60"
    ) else (
        set /a "Minutes=00"
    )
    if !Minutes! GEQ 60 (
        set /a "Hours=!Minutes!/60"
    ) else (
        set /a "Hours=00"
    )
    if !Hours! GEQ 24 (
        set /a "Days=!Hours!/24"
    ) else (
        set /a "Days=0"
    )
    set /a "T_L_H=!Hours!-(!Days!*24)"
    set /a "T_L_M=!Minutes!-(!Hours!*60)"
    set /a "T_L_S=!Seconds!-(!Minutes!*60)"
    set "T_L_Ho=0!T_L_H!"
    set "T_L_Mi=0!T_L_M!"
    set "T_L_Se=0!T_L_S!"
    TITLE Test - Percent done : !percent!%%
    echo.
    echo Time Left : !Days! Days !T_L_Ho:~-2!:!T_L_Mi:~-2!:!T_L_Se:~-2!
    echo.
    echo Total pages to be done : %NUMBER%
    echo Pages done : %%x
    echo Rest of the pages : !Total_Left!
    echo Percent done : !percent!%%
    if %%x GEQ %NUMBER_DONE% (
        (echo %%x) > %INFO_FILE%
        timeout 1 > NUL
    )
    cls
)
pause>NUL

Script last time updated 12.1.2018 23:45

Body:
Here is a PowerShell script that will monitor progress using a file containing the current step number. Be sure to create the watch file before starting it.

<#
.SYNOPSIS
This cmdlet displays a progress bar based on monitoring a watch file.

.DESCRIPTION
If no PROMPT string is provided, the $Env:PROMPT string will be used.

.PARAMETER TotalCount
Specify the total number of steps to monitor.

.PARAMETER WatchFile
Specify the path to the file containing the number of steps completed.

.EXAMPLE
Monitor-Progress -TotalCount 10 -WatchFile wf.txt
#>
[CmdletBinding()]
Param (
    [Parameter(Mandatory=$true)]
    [int]$TotalCount

    ,[Parameter(Mandatory=$true)]
    [ValidateScript({Test-Path $_ -PathType 'Leaf'})]
    [string]$WatchFile
)

$currentcount = 0
$previouscount = $currentcount

while ($currentcount -lt $TotalCount) {
    $currentcount = [int32](Get-Content $WatchFile)

    if ($currentcount -ne $previouscount) {
        Write-Progress -Activity "Watching long progress" `
            -percentComplete ($currentcount / $TotalCount*100)
        $previouscount = $currentcount
    }
}

If you need to run this from the cmd.exe shell, you can:

powershell -NoProfile -File Monitor-Progress.ps1 -TotalCount 5 -WatchFile wf.txt


问:
Current date in SAP HANA and difference between dates
I am trying to write a small SQL statement in HANA Studio in scripted calculation view .

The example data set is as below:

I want to select all the ships that are departing five days from prior today (4th December, 2017) and after today.

The output should be

```<code>  B           09/12/2017
  D           29/12/2017
</code>```

What is the SQL function that I should use and how to figure out todays date in HANA studio and as well as the difference between today's date and date in each record?

UPDATE 1

```<code>SHIP_NAME   DATE_OF_DEPARTURE(DD/MM/YYYY)
   A           15/12/2017
   B           09/12/2017
   c           30/12/2017
   D           29/12/2017
</code>```

Can anybody figure out any issues with this statement? It's not working.

SELECT T1."SHIP_NAME" AS "Ship Name" ,
DAYS_BETWEEN (CURRENT_DATE,T1."DATE_OF_DEPARTURE") AS "Days Between"
FROM "_SYS_BI"."M_SHIP_DEPARTURE" as T1;
```

@Lars Br.  a little help

答:
use the documentation, Luke!
  :)

If you did, you’d find that thecurrent_date gives you the, well, current date.

ContentLicense: CC BY-SA 4.0

Body:
I am trying to write a small SQL statement in HANA Studio in scripted calculation view .

The example data set is as below:

I want to select all the ships that are departing five days from prior today (4th December, 2017) and after today.

The output should be

  B           09/12/2017
  D           29/12/2017

What is the SQL function that I should use and how to figure out todays date in HANA studio and as well as the difference between today's date and date in each record?

UPDATE 1

SHIP_NAME   DATE_OF_DEPARTURE(DD/MM/YYYY)
   A           15/12/2017
   B           09/12/2017
   c           30/12/2017
   D           29/12/2017

Can anybody figure out any issues with this statement? It's not working.

SELECT T1."SHIP_NAME" AS "Ship Name" ,
DAYS_BETWEEN (CURRENT_DATE,T1."DATE_OF_DEPARTURE") AS "Days Between"
FROM "_SYS_BI"."M_SHIP_DEPARTURE" as T1;

@Lars Br.  a little help


问:
Want to show Busy Loading message with percentage download when form will load using JQuery
suppose my page content is huge so in my asp.net application i want to show busy icon with percentage downloading the content in client side. i saw many flash and sliver light site that they show busy icon and also they show percentage that means how much content has been loading in client machine. how could i achieve this using JQuery and when page content has been downloaded in client machine the busy icon goes out and actual page content will display.

please me with sample code to achieve it. thanks

答:
I would recommend something like Uploadify. It does require a flash plugin. This is by far the easiest way.

http://www.uploadify.com/

Here is an example (ASP.NET MVC):

http://blog.bobcravens.com/2010/02/upload-files-with-progress-using-uploadify/

[Update] If you are trying to lazy load images, then use the jquery lazyload plugin. This only loads images that are in the current viewing area. As you scroll down, it fetches the next images. I use it on my blog page.

http://blog.bobcravens.com

View source and you will see (around line 13) a script that sets lazy loading on all post images.

Bob

ContentLicense: CC BY-SA 2.5


问:
3rd party jars outside of ear to be accessed from classes inside the ear
I want to use a 3rd party jar in my application. But its too huge in size. So i want to access it without embedding it in the .ear file. How can i access 3rd party jars outside of ear from classes inside the ear.

I have tried to add the jar files to the lib folder on the server where its deployed. But its not working. Also in clustered environment i will have to keep copies of it on each server.

How can i avoid this. Can i somehow remotely access the 3rd party jar.

3rd party jars outside of ear to be accessed from classes inside the ear

答:
The implementation of this behaviour is not defined by current Java EE specifications. However, most vendors will provide some way of adding client libraries such as this.

Therefore, you need to look to your vendor's documentation to accomplish this.


问:
I want you to help me prepare a detailed customer statement report
The purpose of the report is to provide a detailed account of the customer showing the balance after each transaction between two dates and balance before the start date

I have a view from three tables in SQL Server. I want to extract the evidence from it on three basis dates beginning and end date. However, the previous balance is displayed on the client at the beginning of the report. How can this be done knowing that there is no balance column in the view .
I use stored procedures

I want the report outputs to be like this

I use this code but I have problem

```<code>declare @id_customer int
;with initial as(
  select *
  from result
  where id_customer= @id_customer
),report as(
  select r.id,[balance]=isnull((select sum(b.debit-b.credit)
               from initial b
               where b.[date]<r.[date]) + r.debit - r.credit ,r.debit-r.credit)
  from initial r
)

 select [Operation type] = type,
        reference_no = r.id,
        [description],
        [Debit] = debit,
        [Credit] = credit,
        [Balance] = b.balance
 from result r
 inner join report b on b.id = r.id
 where r.id_customer = @id_customer
 order by r.[date]
</code>```

some records come towc

picture

答:
Try this one, it's hard to guess without example data, but should work.
I assumed that transaction ID is incremental, so correct me if I'm wrong:</p>

```<code>declare @id_customer int = 2
;with initial as(
  select *
  from result
  where id_customer= @id_customer
),report as(
  select r.id,[balance]=isnull((select sum(b.debit-b.credit)
   from initial b
   where b.[date]<=r.[date] and b.[id]<r.[id] ) +
   r.debit - r.credit ,r.debit-r.credit),r.date

  from initial r

)

 select [Operation type] = r.type,
        reference_no = r.id,
        [description] = r.description,
        [Debit] = r.debit,
        [Credit] = r.credit,
        [Balance] = b.balance,
        [Date] = r.date
 from result r
 inner join report b on b.id = r.id
 where r.id_customer = @id_customer
 group by r.id, r.type,r.debit,r.credit,r.date,r.description,b.balance
 order by r.[date]
</code>```

Body:
The purpose of the report is to provide a detailed account of the customer showing the balance after each transaction between two dates and balance before the start date

I have a view from three tables in SQL Server. I want to extract the evidence from it on three basis dates beginning and end date. However, the previous balance is displayed on the client at the beginning of the report. How can this be done knowing that there is no balance column in the view .
I use stored procedures

I want the report outputs to be like this

I use this code but I have problem

declare @id_customer int
;with initial as(
  select *
  from result
  where id_customer= @id_customer
),report as(
  select r.id,[balance]=isnull((select sum(b.debit-b.credit)
               from initial b
               where b.[date]<r.[date]) + r.debit - r.credit ,r.debit-r.credit)
  from initial r
)

 select [Operation type] = type,
        reference_no = r.id,
        [description],
        [Debit] = debit,
        [Credit] = credit,
        [Balance] = b.balance
 from result r
 inner join report b on b.id = r.id
 where r.id_customer = @id_customer
 order by r.[date]

some records come towc

picture

Body:
Try this one, it's hard to guess without example data, but should work.
I assumed that transaction ID is incremental, so correct me if I'm wrong:

declare @id_customer int = 2
;with initial as(
  select *
  from result
  where id_customer= @id_customer
),report as(
  select r.id,[balance]=isnull((select sum(b.debit-b.credit)
   from initial b
   where b.[date]<=r.[date] and b.[id]<r.[id] ) +
   r.debit - r.credit ,r.debit-r.credit),r.date

  from initial r

)

 select [Operation type] = r.type,
        reference_no = r.id,
        [description] = r.description,
        [Debit] = r.debit,
        [Credit] = r.credit,
        [Balance] = b.balance,
        [Date] = r.date
 from result r
 inner join report b on b.id = r.id
 where r.id_customer = @id_customer
 group by r.id, r.type,r.debit,r.credit,r.date,r.description,b.balance
 order by r.[date]


问:
How to swap parameters in Shell command
I have a command with parameters in shell. like

```<code>Command -a -b
</code>```

assume a b are very long directory name, and they are not always the first and last parameters.

However, I need to use this command again. I use ctrl+p to go back the command, but this time I need to reverse a b order.

```<code>Command -b -a
</code>```

Instead of retyping them again, is there any way to fast swap them?

Thanks in advance.

答:
2022 update

You can easily cut and paste arguments, I often cut the last argument and paste it into a different place. Ctrl-W will cut the argument before the cursor, and Ctrl-Y will paste it.

```<code>$ # Cursor position is shown as |
$ ls foo bar|

$ # Press <Ctrl-W> to cut the argument just before the cursor
$ ls foo |

$ # Now press <Alt-B> to move the cursor one argument back
$ ls |foo

$ # Now press <Ctrl-Y> to paste the cut argument
$ ls bar|foo

$ # Now press <space> to insert a space between the arguments
$ ls bar |foo

$ # You can safely press <enter> while the cursor is in the middle of the line
$ ls bar |foo
bar foo
</code>```

Title: How to swap parameters in Shell command

Body:
I have a command with parameters in shell. like

Command -a -b

assume a b are very long directory name, and they are not always the first and last parameters.

However, I need to use this command again. I use ctrl+p to go back the command, but this time I need to reverse a b order.

Command -b -a

Instead of retyping them again, is there any way to fast swap them?

Thanks in advance.

Body:
2022 update

You can easily cut and paste arguments, I often cut the last argument and paste it into a different place. Ctrl-W will cut the argument before the cursor, and Ctrl-Y will paste it.

$ # Cursor position is shown as |
$ ls foo bar|

$ # Press <Ctrl-W> to cut the argument just before the cursor
$ ls foo |

$ # Now press <Alt-B> to move the cursor one argument back
$ ls |foo

$ # Now press <Ctrl-Y> to paste the cut argument
$ ls bar|foo

$ # Now press <space> to insert a space between the arguments
$ ls bar |foo

$ # You can safely press <enter> while the cursor is in the middle of the line
$ ls bar |foo
bar foo


问:
How to make VSTS email me if somebody @mention me on discussion
I would like to email if somebody @mention me on discussion.
I know that it is possible :)
I have tried to set on setting --> notification, but without result.

Thank you!

答:
It’s already the default manners.

When someone is mentioned in work item discussion, he/she will receive the email notification by default.

You can also find achieved request here.


问:
Unexpected String From Win32 UuidToString() Call
I have a simple class that generates a GUID by calling CoCreateGuid(). I then pass the result to UuidToString().

Most of the time I get a string in the format:

e0e3e4b5-6f13-4043-b6c6-488c8b85cbd1

However, on a few machines the result looks something like this:

0-40:61:86:C2:4E:4F

Can anybody explain this unexpected behavior? Is the second form even a GUID?

UPDATE: I have found the source of the error and it turns out that UuidToString() is not returning the string I thought it was.

Thanks for all the answers.

答: Bizarre.  RPC is an oddball API though, it's very old and quirks are heavily preserved.  I'd recommend you use StringFromGUID2() instead.  Having two ways to accomplish the same thing is always a telltale sign, later is better.</p>


问:
Could not connect zipkin docker container to mysql container
I have zipkin server running as spring boot app. I have exported jar to docker container.

My dockerfile looks like:

```<code>FROM openjdk:8-jdk-alpine
WORKDIR /
ADD zipkinmysql-0.0.1-SNAPSHOT.jar zipkinmysql-0.0.1-SNAPSHOT.jar
EXPOSE 9411
CMD java -jar zipkinmysql-0.0.1-SNAPSHOT.jar
</code>```

I have one mysql container. Got this from official docker hub.

```<code>docker run -p 3306:3306 --name mysqlDocker -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=zipkin -d mysql
</code>```

when I link my zipkin container to mysql using this command :

```<code>docker run -p 9411:9411 --name zipkinServer --link mysqlDocker -d zipkin
</code>```

I am getting refused connection exception

```<code>com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.Util.getInstance(Util.java:408) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2163) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2088) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310) ~[tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:718) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:650) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:468) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) [spring-jdbc-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) [spring-jdbc-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:46) [spring-jdbc-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:176) [spring-boot-autoconfigure-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runSchemaScripts(DataSourceInitializer.java:85) [spring-boot-autoconfigure-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.init(DataSourceInitializer.java:77) [spring-boot-autoconfigure-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1575) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:220) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1011) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:335) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerPostProcessor.postProcessAfterInitialization(DataSourceInitializerPostProcessor.java:62) [spring-boot-autoconfigure-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1588) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1131) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1131) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1148) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) [spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) [spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at com.example.ZipkinmysqlApplication.main(ZipkinmysqlApplication.java:13) [classes!/:0.0.1-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [zipkinmysql-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [zipkinmysql-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [zipkinmysql-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [zipkinmysql-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
</code>```

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Although if I run my jar from host OS then it is able to connect mysql container and I can see spans stored in mysql db

My application.yml is :

```<code>server:
  port: 9411

spring:
  application:
    name: zipkin-server
  datasource:
    schema: classpath:/mysql.sql
    url: jdbc:mysql://0.0.0.0:3306/zipkin?autoReconnect=true
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
    initialize: true
    continue-on-error: true
  sleuth:
    enabled: false

zipkin:
  storage:
      type: mysql
</code>```

How can I connect java docker container to mysql docker container?

I have already explored this link.

答:
When connecting to the mysql container while using links, you need to use the container name as a hostname.

Change the connection string to:

```<code>url: jdbc:mysql://${mysqlHost:0.0.0.0}:3306/zipkin?autoReconnect=true
</code>```

And when starting the zipkin container, set the env variable:

```<code>docker run -p 9411:9411 --name zipkinServer --link mysqlDocker -d -e mysqlHost=mysqlDocker zipkin
</code>```

Body:
I have zipkin server running as spring boot app. I have exported jar to docker container.

My dockerfile looks like:

FROM openjdk:8-jdk-alpine
WORKDIR /
ADD zipkinmysql-0.0.1-SNAPSHOT.jar zipkinmysql-0.0.1-SNAPSHOT.jar
EXPOSE 9411
CMD java -jar zipkinmysql-0.0.1-SNAPSHOT.jar

I have one mysql container. Got this from official docker hub.

docker run -p 3306:3306 --name mysqlDocker -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=zipkin -d mysql

when I link my zipkin container to mysql using this command :

docker run -p 9411:9411 --name zipkinServer --link mysqlDocker -d zipkin

I am getting refused connection exception

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.Util.getInstance(Util.java:408) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2163) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2088) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328) ~[mysql-connector-java-5.1.40.jar!/:5.1.40]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310) ~[tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:718) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:650) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:468) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) [tomcat-jdbc-8.5.6.jar!/:na]
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) [spring-jdbc-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) [spring-jdbc-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.jdbc.datasource.init.DatabasePopulatorUtils.execute(DatabasePopulatorUtils.java:46) [spring-jdbc-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runScripts(DataSourceInitializer.java:176) [spring-boot-autoconfigure-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.runSchemaScripts(DataSourceInitializer.java:85) [spring-boot-autoconfigure-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializer.init(DataSourceInitializer.java:77) [spring-boot-autoconfigure-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:311) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:134) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1575) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:220) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1011) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:335) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerPostProcessor.postProcessAfterInitialization(DataSourceInitializerPostProcessor.java:62) [spring-boot-autoconfigure-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1588) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1131) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1128) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:207) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1131) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1059) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1148) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:754) [spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) [spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) [spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE]
    at com.example.ZipkinmysqlApplication.main(ZipkinmysqlApplication.java:13) [classes!/:0.0.1-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [zipkinmysql-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [zipkinmysql-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [zipkinmysql-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [zipkinmysql-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]

Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Although if I run my jar from host OS then it is able to connect mysql container and I can see spans stored in mysql db

My application.yml is :

server:
  port: 9411

spring:
  application:
    name: zipkin-server
  datasource:
    schema: classpath:/mysql.sql
    url: jdbc:mysql://0.0.0.0:3306/zipkin?autoReconnect=true
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
    initialize: true
    continue-on-error: true
  sleuth:
    enabled: false

zipkin:
  storage:
      type: mysql

How can I connect java docker container to mysql docker container?

I have already explored this link.

Body:
When connecting to the mysql container while using links, you need to use the container name as a hostname.

Change the connection string to:

url: jdbc:mysql://${mysqlHost:0.0.0.0}:3306/zipkin?autoReconnect=true

And when starting the zipkin container, set the env variable:

docker run -p 9411:9411 --name zipkinServer --link mysqlDocker -d -e mysqlHost=mysqlDocker zipkin


问:
Get XML data - Jquery - Filter
I´m trying to use jquery filter function and parse XML but are having issues.
My XML looks like this:

```<code><root>
    <data name="0121C395-AFCE-49C8-A163-55E24325D691" xml:space="preserve">
        <value>Report an incident</value>
    </data>
    <data name="0121C395-AFCE-49C8-A163-55E24325D691_descr" xml:space="preserve">
        <value>In this service it's possible to report incidents.</value>
    </data>
    <data name="0121C395-AFCE-49C8-A163-55E24325D691_short" xml:space="preserve">
        <value>Report Incident</value>
    </data>
</root>
</code>```

And my Jquery looks like this:

```<code>$(document).ready(function(){
    $.ajax({
        type: "GET",
        url: "http://localhost/servicemarket/ReachOut/Services.xml",
        dataType: "xml",
        success: function(xml){
            var dataVal = $(xml).find('data').filter(function(){
                return $('data', this).attr('name') == '0121C395-AFCE-49C8-A163-55E24325D691';
            });
            dataVal.each(function(index, data){
                console.log($(data).find('value').text());
            });
        },
        error: function() {
            alert("An error occurred while processing XML file.");
        }
    });
});
</code>```

My goal is to get node value based on incoming data attribute.
All help are much appreciated! :)
Thank you!!

答:
Your code should be slightly modified:

```<code>    $(document).ready(function(){
    $.ajax({
        type: "GET",
         url: "http://localhost/servicemarket/ReachOut/Services.xml"
        dataType: "xml",
        success: function(xml){
            var dataVal = $(xml).find('data').filter(function(){

                return $(this).attr('name') == '0121C395-AFCE-49C8-A163-55E24325D691';
            });
            //console.log(dataVal);
            dataVal.each(function(index, data){
                console.log($(data).find('value').text());
            });
        },
        error: function() {
            alert("An error occurred while processing XML file.");
        }
    });
});
</code>```

So, use $(this) to get current (found by find()) object. Your $('data', this) returned an empty object, because data doesn't contain another data tag inside (if i understand error correctly).

Title: Get XML data - Jquery - Filter

Body:
I´m trying to use jquery filter function and parse XML but are having issues.
My XML looks like this:

<root>
    <data name="0121C395-AFCE-49C8-A163-55E24325D691" xml:space="preserve">
        <value>Report an incident</value>
    </data>
    <data name="0121C395-AFCE-49C8-A163-55E24325D691_descr" xml:space="preserve">
        <value>In this service it's possible to report incidents.</value>
    </data>
    <data name="0121C395-AFCE-49C8-A163-55E24325D691_short" xml:space="preserve">
        <value>Report Incident</value>
    </data>
</root>

And my Jquery looks like this:

$(document).ready(function(){
    $.ajax({
        type: "GET",
        url: "http://localhost/servicemarket/ReachOut/Services.xml",
        dataType: "xml",
        success: function(xml){
            var dataVal = $(xml).find('data').filter(function(){
                return $('data', this).attr('name') == '0121C395-AFCE-49C8-A163-55E24325D691';
            });
            dataVal.each(function(index, data){
                console.log($(data).find('value').text());
            });
        },
        error: function() {
            alert("An error occurred while processing XML file.");
        }
    });
});

My goal is to get node value based on incoming data attribute.
All help are much appreciated! :)
Thank you!!

Body:
Your code should be slightly modified:

    $(document).ready(function(){
    $.ajax({
        type: "GET",
         url: "http://localhost/servicemarket/ReachOut/Services.xml"
        dataType: "xml",
        success: function(xml){
            var dataVal = $(xml).find('data').filter(function(){

                return $(this).attr('name') == '0121C395-AFCE-49C8-A163-55E24325D691';
            });
            //console.log(dataVal);
            dataVal.each(function(index, data){
                console.log($(data).find('value').text());
            });
        },
        error: function() {
            alert("An error occurred while processing XML file.");
        }
    });
});

So, use $(this) to get current (found by find()) object. Your $('data', this) returned an empty object, because data doesn't contain another data tag inside (if i understand error correctly).


问:
how to move multiple objects after scene.add(object);
I am using Three.js to create an animation of 100 cubes.
For each cube I set its geometry and material and then add it to the scene with:
scene.add(cube);
I have been storing the positions of the cubes in three arrays: cube_x[99] cube_y[99] cube_z[99]

I do not know how to tell the renderer their positions as they are modified. The following works for one cube when I have only one cube in the scene:

cube.position.x=300;
cube.position.y=000;

I tried making cube into an array to hold the xyz positions of 100 cubes. But I can not seem to call scene.add(cube[i]);

How can I update the position of 100 cubes after scene.add(cube);
How do I let three.js know which cube I am trying to move?

Thanks - javascript beginner

答:
You would basically store a reference to each cube in an array:

```<code>// reference array
var cubes = [];

// create cube mesh
var cube = new THREE.Mesh(new THREE.BoxGeometry(), someMaterial);

// push a reference to array
cubes.push(cube);

// add same cube to scene
scene.add(cube);
</code>```

Now you can iterate over each cube and move it:

```<code>cubes.forEach(function(cube) {
  cube.position.z -= 0.1;  // move for example in Z direction
});
</code>```

You would do this within your animation loop.

// Setup a simple demo scene
var scene = new THREE.Scene();
var cam = new THREE.PerspectiveCamera(40, innerWidth / innerHeight, 0.1, maxDist);
var renderer = new THREE.WebGLRenderer({antialias:true});
renderer.setPixelRatio(devicePixelRatio);
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);

// STore our cubes somewhere, dist for random generation and clipping
var cubes = [], maxDist = 500, r = Math.random, materials = [];
for(var i = 0; i < 7; i++) materials.push(new THREE.MeshBasicMaterial({color: (r()*0xffffff)&0xffffff|0x999999}));

// Add and store some cubes
for(i = 0; i < 3000; i++) {
  var cube = new THREE.Mesh(new THREE.BoxBufferGeometry(), materials[i % materials.length]);
  cubes.push(cube); // store to our array
  cube.position.set(r()*maxDist*2-maxDist, r()*maxDist*2-maxDist, r()*maxDist*2-maxDist); // random positions
}
scene.add(...cubes); //es6, add to scene
cam.position.z = maxDist;

// Animate cubes
function loop(time) {
  for(i = 0, cube; i < cubes.length; i++) {  // for each cube do:
   cube = cubes[i];
   cube.position.z -= 1; // move on Z in this demo
    if (cube.position.z < -maxDist) cube.position.z = maxDist;  // reset position for demo
  }
  cam.rotation.z = Math.sin(time*0.0003);      // add some camera action
  cam.rotation.y = Math.sin(time*0.0005)*0.3;  // add some camera action
  renderer.render(scene, cam);                 // render everything
  requestAnimationFrame(loop)
};
requestAnimationFrame(loop)```
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {margin:0:overflow:hidden}</code>```

```

Body:
You would basically store a reference to each cube in an array:

// reference array
var cubes = [];

// create cube mesh
var cube = new THREE.Mesh(new THREE.BoxGeometry(), someMaterial);

// push a reference to array
cubes.push(cube);

// add same cube to scene
scene.add(cube);

Now you can iterate over each cube and move it:

cubes.forEach(function(cube) {
  cube.position.z -= 0.1;  // move for example in Z direction
});

You would do this within your animation loop.

// Setup a simple demo scene
var scene = new THREE.Scene();
var cam = new THREE.PerspectiveCamera(40, innerWidth / innerHeight, 0.1, maxDist);
var renderer = new THREE.WebGLRenderer({antialias:true});
renderer.setPixelRatio(devicePixelRatio);
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);

// STore our cubes somewhere, dist for random generation and clipping
var cubes = [], maxDist = 500, r = Math.random, materials = [];
for(var i = 0; i < 7; i++) materials.push(new THREE.MeshBasicMaterial({color: (r()*0xffffff)&0xffffff|0x999999}));

// Add and store some cubes
for(i = 0; i < 3000; i++) {
  var cube = new THREE.Mesh(new THREE.BoxBufferGeometry(), materials[i % materials.length]);
  cubes.push(cube); // store to our array
  cube.position.set(r()*maxDist*2-maxDist, r()*maxDist*2-maxDist, r()*maxDist*2-maxDist); // random positions
}
scene.add(...cubes); //es6, add to scene
cam.position.z = maxDist;

// Animate cubes
function loop(time) {
  for(i = 0, cube; i < cubes.length; i++) {  // for each cube do:
   cube = cubes[i];
   cube.position.z -= 1; // move on Z in this demo
    if (cube.position.z < -maxDist) cube.position.z = maxDist;  // reset position for demo
  }
  cam.rotation.z = Math.sin(time*0.0003);      // add some camera action
  cam.rotation.y = Math.sin(time*0.0005)*0.3;  // add some camera action
  renderer.render(scene, cam);                 // render everything
  requestAnimationFrame(loop)
};
requestAnimationFrame(loop)

body {margin:0:overflow:hidden}

<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/88/three.min.js"></script>


问:
Host Not Allowed 192...224 even though it is already in my django project
I have a Django project that I have pushed to docker and then a digital ocean server for live testing in a working environment. In the settings file, I have an IP address from my digital ocean server added to the allowed host portion of the settings file, but I am getting the following error:

```<code>DisallowedHost at /
Invalid HTTP_HOST header: '192...244:8000'. You may need to add '192...244' to ALLOWED_HOSTS.
</code>```

Here is the code I have

```<code>ALLOWED_HOSTS = ['192...244', 'localhost', '127.0.0.1']
</code>```

I didn't add the full IP, even though I have the full IP in my files.

答:
Try this:</p>

```<code>ALLOWED_HOSTS = ['*']
</code>```

Body:
I have a Django project that I have pushed to docker and then a digital ocean server for live testing in a working environment. In the settings file, I have an IP address from my digital ocean server added to the allowed host portion of the settings file, but I am getting the following error:

DisallowedHost at /
Invalid HTTP_HOST header: '192...244:8000'. You may need to add '192...244' to ALLOWED_HOSTS.

Here is the code I have

ALLOWED_HOSTS = ['192...244', 'localhost', '127.0.0.1']

I didn't add the full IP, even though I have the full IP in my files.

Body:
Try this:

ALLOWED_HOSTS = ['*']


问:
primeng 5.0.2 doesn't work with Angular 4?
I'm developing an angular application, and when I tried to install the latest version of primeng , I'm getting version mismatch error as shown below ,

I want to use the latest version primeng 5.0.2 for its upgraded features in my Angular 4 project  , won't this work ?

答:
No it won't work because of AOT constraints.

From PrimeNG blog :

Angular 5 Support

PrimeNG 5 fully support Angular 5, if your project is on Angular 4,
  the PrimeNG version to use would be 4.x as PrimeNG 5 does not work on
  Angular 4 due to AOT constraints.

So you have to upgrade Angular from 4 to 5.


问:
What user should own /usr/local/mysql on Mac?
What should the file owner & group be of /usr/local/mysql and all contained files & directories? MySQL was working fine, but after I did sudo chown -R $USER:staff /usr/local to install Homebrew, MySQL couldn't automatically start on startup, and on the MySQL Preferences panel, I got "Warning: The /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql' user," and when I clicked Start MySQL Server, it didn't connect.

To fix this, I ran sudo chown -R _mysql:wheel /usr/local/mysql/data. Then, I closed & opened System Preferences. The warning went away, and when I clicked Start MySQL Server, it started!

MySQL seems to be responding fine now, but I just guessed at this solution. Is what I did correct?

答:
Looks valid to me. This is what my mysql folder looks like:

```<code>drwxr-xr-x  17 root    wheel    578 May  7  2010 .
drwxr-xr-x   8 root    wheel    272 Jun 11  2010 ..
-rw-r--r--   1 root    wheel  17987 May  7  2010 COPYING
-rw-r--r--   1 root    wheel   5139 May  7  2010 EXCEPTIONS-CLIENT
-rw-r--r--   1 root    wheel   9339 May  7  2010 INSTALL-BINARY
-rw-r--r--   1 root    wheel  62989 May  7  2010 README
drwxr-xr-x  46 root    wheel   1564 May  7  2010 bin
drwxr-x---  15 _mysql  wheel    510 Jan 21 08:15 data
drwxr-xr-x   4 root    wheel    136 May  7  2010 docs
drwxr-xr-x  34 root    wheel   1156 May  7  2010 include
drwxr-xr-x  22 root    wheel    748 Jun  3  2010 lib
drwxr-xr-x   4 root    wheel    136 May  7  2010 man
drwxr-xr-x  15 root    wheel    510 May  7  2010 mysql-test
drwxr-xr-x   3 root    wheel    102 May  7  2010 scripts
drwxr-xr-x  35 root    wheel   1190 May  7  2010 share
drwxr-xr-x  29 root    wheel    986 May  7  2010 sql-bench
drwxr-xr-x  16 root    wheel    544 May  7  2010 support-files
</code>```

How did you install MySQL it if it didn't hook everything up correctly itself?

EDIT: and this is the general flavor of the data folder:

```<code>drwxr-x---  15 _mysql  wheel       510 Jan 24 08:15 .
drwxr-xr-x  17 root    wheel       578 May  7  2010 ..
-rw-rw----   1 _mysql  wheel    158773 Jan 24 08:16 $USER.local.err
-rw-rw----   1 _mysql  wheel         4 Jan 24 08:15 $USER.local.pid
drwx------   6 _mysql  wheel       204 Jun 16  2010 $SOME_DB_NAME1
drwx------   6 _mysql  wheel       204 Jun  8  2010 $SOME_DB_NAME2
drwx------  15 _mysql  wheel       510 Jan 18 11:23 $SOME_DB_NAME3
drwx------  12 _mysql  wheel       408 Jan 20 14:40 $SOME_DB_NAME4
-rw-rw----   1 _mysql  wheel   5242880 Jan 24 08:15 ib_logfile0
-rw-rw----   1 _mysql  wheel   5242880 Jan 24 08:15 ib_logfile1
-rw-rw----   1 _mysql  wheel  18874368 Jan 21 17:31 ibdata1
drwx------  85 _mysql  wheel      2890 Jun  3  2010 $SOME_DB_NAME5
drwx------  85 _mysql  wheel      2890 Jun  3  2010 $SOME_DB_NAME6
drwxr-x---  71 _mysql  wheel      2414 Jun  3  2010 mysql
drwx------  21 _mysql  wheel       714 Aug 31 17:27 $SOME_DB_NAME7
</code>```

I don't run Homebrew on my machine, so I don't know if this is of much help as far as that goes.

Body:
Looks valid to me. This is what my mysql folder looks like:

drwxr-xr-x  17 root    wheel    578 May  7  2010 .
drwxr-xr-x   8 root    wheel    272 Jun 11  2010 ..
-rw-r--r--   1 root    wheel  17987 May  7  2010 COPYING
-rw-r--r--   1 root    wheel   5139 May  7  2010 EXCEPTIONS-CLIENT
-rw-r--r--   1 root    wheel   9339 May  7  2010 INSTALL-BINARY
-rw-r--r--   1 root    wheel  62989 May  7  2010 README
drwxr-xr-x  46 root    wheel   1564 May  7  2010 bin
drwxr-x---  15 _mysql  wheel    510 Jan 21 08:15 data
drwxr-xr-x   4 root    wheel    136 May  7  2010 docs
drwxr-xr-x  34 root    wheel   1156 May  7  2010 include
drwxr-xr-x  22 root    wheel    748 Jun  3  2010 lib
drwxr-xr-x   4 root    wheel    136 May  7  2010 man
drwxr-xr-x  15 root    wheel    510 May  7  2010 mysql-test
drwxr-xr-x   3 root    wheel    102 May  7  2010 scripts
drwxr-xr-x  35 root    wheel   1190 May  7  2010 share
drwxr-xr-x  29 root    wheel    986 May  7  2010 sql-bench
drwxr-xr-x  16 root    wheel    544 May  7  2010 support-files

How did you install MySQL it if it didn't hook everything up correctly itself?

EDIT: and this is the general flavor of the data folder:

drwxr-x---  15 _mysql  wheel       510 Jan 24 08:15 .
drwxr-xr-x  17 root    wheel       578 May  7  2010 ..
-rw-rw----   1 _mysql  wheel    158773 Jan 24 08:16 $USER.local.err
-rw-rw----   1 _mysql  wheel         4 Jan 24 08:15 $USER.local.pid
drwx------   6 _mysql  wheel       204 Jun 16  2010 $SOME_DB_NAME1
drwx------   6 _mysql  wheel       204 Jun  8  2010 $SOME_DB_NAME2
drwx------  15 _mysql  wheel       510 Jan 18 11:23 $SOME_DB_NAME3
drwx------  12 _mysql  wheel       408 Jan 20 14:40 $SOME_DB_NAME4
-rw-rw----   1 _mysql  wheel   5242880 Jan 24 08:15 ib_logfile0
-rw-rw----   1 _mysql  wheel   5242880 Jan 24 08:15 ib_logfile1
-rw-rw----   1 _mysql  wheel  18874368 Jan 21 17:31 ibdata1
drwx------  85 _mysql  wheel      2890 Jun  3  2010 $SOME_DB_NAME5
drwx------  85 _mysql  wheel      2890 Jun  3  2010 $SOME_DB_NAME6
drwxr-x---  71 _mysql  wheel      2414 Jun  3  2010 mysql
drwx------  21 _mysql  wheel       714 Aug 31 17:27 $SOME_DB_NAME7

I don't run Homebrew on my machine, so I don't know if this is of much help as far as that goes.


问:
Creating a single barplot with different colors with pandas and matplotlib
I have two dfs, for which I want to create a single bar plot,
each bar needs its own color depending on which df it came from.

```<code># Ages < 20
df1.tags = ['locari', 'ママコーデ', 'ponte_fashion', 'kurashiru', 'fashion']
df1.tag_count = [2162, 1647, 1443, 1173, 1032]

# Ages 20 - 24
df2.tags= ['instagood', 'ootd', 'fashion', 'followme', 'love']
df2.tag_count = [6523, 4576, 3986, 3847, 3599]
</code>```

How do I create such a plot?

P.S. The original df is way bigger. Some words may overlap, but I want them to have different colors as well

答:
Your data frame tag_counts are just simple lists, so you can use standard mpl bar plots to plot both of them in the same axis. This answer assumes that both dataframes have the same length.

```<code>import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

# Create dataframes
df1=pd.DataFrame()
df2=pd.DataFrame()

# Ages < 20
df1.tags = ['locari', 'blub', 'ponte_fashion', 'kurashiru', 'fashion']
df1.tag_count = [2162, 1647, 1443, 1173, 1032]

# Ages 20 - 24
df2.tags= ['instagood', 'ootd', 'fashion', 'followme', 'love']
df2.tag_count = [6523, 4576, 3986, 3847, 3599]

# Create figure
fig=plt.figure()
ax=fig.add_subplot(111)

# x-coordinates
ind1 = np.arange(len(df1.tag_count))
ind2 = np.arange(len(df2.tag_count))
width = 0.35

# Bar plot for df1
ax.bar(ind1,df1.tag_count,width,color='r')

# Bar plot for df1
ax.bar(ind2+width,df2.tag_count,width,color='b')

# Create new xticks
ticks=list(ind1+0.5*width)+list(ind2+1.5*width)
ticks.sort()
ax.set_xticks(ticks)

# Sort labels in an alternating way
labels = [None]*(len(df1.tags)+len(df2.tags))
labels[::2] = df1.tags
labels[1::2] = df2.tags
ax.set_xticklabels(labels)

plt.show()
</code>```

This will return  a plot like this

Note that to merge both tags into a single list I assumed that both lists have the same length.

Body:
I have two dfs, for which I want to create a single bar plot,
each bar needs its own color depending on which df it came from.

# Ages < 20
df1.tags = ['locari', 'ママコーデ', 'ponte_fashion', 'kurashiru', 'fashion']
df1.tag_count = [2162, 1647, 1443, 1173, 1032]

# Ages 20 - 24
df2.tags= ['instagood', 'ootd', 'fashion', 'followme', 'love']
df2.tag_count = [6523, 4576, 3986, 3847, 3599]

How do I create such a plot?

P.S. The original df is way bigger. Some words may overlap, but I want them to have different colors as well

Body:
Your data frame tag_counts are just simple lists, so you can use standard mpl bar plots to plot both of them in the same axis. This answer assumes that both dataframes have the same length.

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

# Create dataframes
df1=pd.DataFrame()
df2=pd.DataFrame()

# Ages < 20
df1.tags = ['locari', 'blub', 'ponte_fashion', 'kurashiru', 'fashion']
df1.tag_count = [2162, 1647, 1443, 1173, 1032]

# Ages 20 - 24
df2.tags= ['instagood', 'ootd', 'fashion', 'followme', 'love']
df2.tag_count = [6523, 4576, 3986, 3847, 3599]

# Create figure
fig=plt.figure()
ax=fig.add_subplot(111)

# x-coordinates
ind1 = np.arange(len(df1.tag_count))
ind2 = np.arange(len(df2.tag_count))
width = 0.35

# Bar plot for df1
ax.bar(ind1,df1.tag_count,width,color='r')

# Bar plot for df1
ax.bar(ind2+width,df2.tag_count,width,color='b')

# Create new xticks
ticks=list(ind1+0.5*width)+list(ind2+1.5*width)
ticks.sort()
ax.set_xticks(ticks)

# Sort labels in an alternating way
labels = [None]*(len(df1.tags)+len(df2.tags))
labels[::2] = df1.tags
labels[1::2] = df2.tags
ax.set_xticklabels(labels)

plt.show()

This will return  a plot like this

Note that to merge both tags into a single list I assumed that both lists have the same length.


问:
GameObject selection within bounding area(Seleting gameObject in general direction via transform comparing)
I want to cast a ray / sphere from a vector(origin) which is inside of a BoxCollider bound and limit its maxDistance so that it won't exceed the bound area and hit only the objects inside this bound with layerMask. How does one achieve this?

Also, if I cast this as a sphereCast and multiple objects were hit how could I get only the object nearest to the center of the sphereCast? I've searched around for quite a while, but couldn't quite get it there.

Edit #1

While I thank you for the previous answers I update this edit for a better elaboration of what I really want to achieve.

When I asked you the initial question it was still vague for me how to resolve the missing rayCast / sphereCast which I do not want either which will eventually miss depending on the size of target / sphereCast radius.

The end goal is to have directional input to select a gameObject and never miss.  I already have this bounding box collecting transforms of gameObjects within in a List, and if I input with say gamepad analog stick giving normalized direction I wanted to choose the one in that general direction. However, I'm aware if I do it in just rayCast / sphereCast I'd have to do multiple casting per input to ensure not missing a target which I thought would be an unnecessary block of code. The ideal thing would be: if normalized input dir: vector2(1,0, 0) the purple target on 2 O'clock position from the origin would be selected.

答:
If you have a Collider as your Bounds, you can simply use Collider.bounds.extents or Collider.bounds.size to get the size of your collider and then (according to your starting position) set the max Size for your Spherecast. E.g. if your SphereCast starts in the middle of a Cube you just use one of the values from Collider.bounds.extents as your max size.

For the second question:
Physics.SphereCastAll will return an array of RaycastHits. These have a property distance which returns the distance from your raycasts origin to the point where the collider was hit. You can simply iterate over the array and use the object with the smallest distance to get the nearest one.

Also I think Physics.SphereCast should return the first object that was hit (so therefore the nearest one), if that is all you want to get. But I'm not sure right now if this always behaves like you want it to, but it might be worth testing as it would be way better for your performance than using the Physics.SphereCastAll method.


答:
You could have a placeholder image, and when the image you want is loaded, you could replace the placeholder with the new source

```<code>var img = new Image();
img.src= "largerImage.png";
img.onload = function() { oldImage.src = img.src; };
</code>```

This could be taken a step further, and the code could be added to the image itself

```<code><img src="http://www.codedigest.com/img/loading.gif"
 onload="var t = this; var img = new Image(); img.src ='http://hardgeek.org/wp-content/uploads/2010/07/firefox-logo-1024x969.jpg'; img.onload = function() { t.src = img.src }" />
</code>```

Which could also be taken a step further, as you might not always have the ability to apply the onload directly like this, just a suggestion.

Title: Want to show Busy Loading message with percentage download when form will load using JQuery

Body:
suppose my page content is huge so in my asp.net application i want to show busy icon with percentage downloading the content in client side. i saw many flash and sliver light site that they show busy icon and also they show percentage that means how much content has been loading in client machine. how could i achieve this using JQuery and when page content has been downloaded in client machine the busy icon goes out and actual page content will display.

please me with sample code to achieve it. thanks

Body:
You could have a placeholder image, and when the image you want is loaded, you could replace the placeholder with the new source

var img = new Image();
img.src= "largerImage.png";
img.onload = function() { oldImage.src = img.src; };

This could be taken a step further, and the code could be added to the image itself

<img src="http://www.codedigest.com/img/loading.gif"
 onload="var t = this; var img = new Image(); img.src ='http://hardgeek.org/wp-content/uploads/2010/07/firefox-logo-1024x969.jpg'; img.onload = function() { t.src = img.src }" />

Which could also be taken a step further, as you might not always have the ability to apply the onload directly like this, just a suggestion.


问:
Unable to find api GoogleSignIn.silentSignIn
I am following the tutorial found here. But I am unable to find the api: GoogleSignIn.silentSignIn() as mentioned in the doc.

Is it deprecated or removed?

If yes, would anyone please correct the guide.

答: That's a mistake in the example, the method is declared in Auth.GoogleSignInApi. See the references.


问:
ExtJS 4.1.1: Custom display text for multi-select combobox
I've got a multi-select combobox whose display value I need to set following the particular schema "Selections [x]", where x corresponds to the number of selected items. Unfortunately, after trying it using a number of different approaches I couldn't find a way to achieve the desired result. Using the fieldSubTpl config or overwriting the valueToRaw() method seem to be the most promising approaches to me. However, I couldn't get either of them to work.

I found a working example of the desired behaviour for ExtJS 6 here. If you select more than one value the combobox displays "x values selected" rather than simply concatenating the selected values.

How can I achieve the same result in ExtJS 4.1.1?

答:
You need to use displayTpl config for combo.

In this FIDDLE, I have created same example in ExtJS 4.x as you provide in ExtJS 6.x. It is working fine. Hope this will guide you or help you to achieve your required solution.

```<code>Ext.create('Ext.form.Panel', {
    renderTo: Ext.getBody(),
    title: 'Multiple Seletion Example in ExtJS 4.x for combo box',
    items: [{
        xtype: 'combo',
        margin: 20,
        fieldLabel: 'Character Name',
        store: Ext.create('Ext.data.Store', {
            fields: ['id', 'name'],
            data: [{
                id: 0,
                name: 'John Snow'
            }, {
                id: 1,
                name: 'Tyrion Lannister'
            }, {
                id: 2,
                name: 'Morgan Dexter'
            }, {
                id: 3,
                name: 'Lannister'
            }, {
                id: 4,
                name: 'Silicon Vally'
            }]
        }),
        displayField: 'name',
        /*
        If you use using this then initially you will see {0 values selected}
           displayTpl: new Ext.XTemplate('{[values instanceof Array ? values.length === 1 ? values[0]["' + combo.displayField + '"] : values.length + " values selected" : values]}'),
        */
        valueField: 'id',
        queryMode: 'local',
        multiSelect: true,
        filterPickList: true,
        listeners: {
            render: function (combo) {
                //Use propery {displayTpl}
                //The template to be used to display selected records inside the text field. An array of the selected records' data will be passed to the template.
                combo.displayTpl = new Ext.XTemplate('{[values instanceof Array ? values.length === 1 ? values[0]["' + combo.displayField + '"] : values.length + " values selected" : values]}');
                /*
                you can also use like below function
                combo.displayTpl = new Ext.XTemplate('{[this.getDisplayField(values)]}', {
                    getDisplayField: function (values) {
                        if (Ext.isArray(values)) {
                            var len = values.length;
                            return len == 1 ? values[0].name : (len + ' values selected');
                        }
                        return values;
                    }
                });*/
            }
        }
    }]
});
</code>```

Body:
You need to use displayTpl config for combo.

In this FIDDLE, I have created same example in ExtJS 4.x as you provide in ExtJS 6.x. It is working fine. Hope this will guide you or help you to achieve your required solution.

Ext.create('Ext.form.Panel', {
    renderTo: Ext.getBody(),
    title: 'Multiple Seletion Example in ExtJS 4.x for combo box',
    items: [{
        xtype: 'combo',
        margin: 20,
        fieldLabel: 'Character Name',
        store: Ext.create('Ext.data.Store', {
            fields: ['id', 'name'],
            data: [{
                id: 0,
                name: 'John Snow'
            }, {
                id: 1,
                name: 'Tyrion Lannister'
            }, {
                id: 2,
                name: 'Morgan Dexter'
            }, {
                id: 3,
                name: 'Lannister'
            }, {
                id: 4,
                name: 'Silicon Vally'
            }]
        }),
        displayField: 'name',
        /*
        If you use using this then initially you will see {0 values selected}
           displayTpl: new Ext.XTemplate('{[values instanceof Array ? values.length === 1 ? values[0]["' + combo.displayField + '"] : values.length + " values selected" : values]}'),
        */
        valueField: 'id',
        queryMode: 'local',
        multiSelect: true,
        filterPickList: true,
        listeners: {
            render: function (combo) {
                //Use propery {displayTpl}
                //The template to be used to display selected records inside the text field. An array of the selected records' data will be passed to the template.
                combo.displayTpl = new Ext.XTemplate('{[values instanceof Array ? values.length === 1 ? values[0]["' + combo.displayField + '"] : values.length + " values selected" : values]}');
                /*
                you can also use like below function
                combo.displayTpl = new Ext.XTemplate('{[this.getDisplayField(values)]}', {
                    getDisplayField: function (values) {
                        if (Ext.isArray(values)) {
                            var len = values.length;
                            return len == 1 ? values[0].name : (len + ' values selected');
                        }
                        return values;
                    }
                });*/
            }
        }
    }]
});