首页 \ 问答 \ logparser TO_TIME输出与sql时间数据类型不匹配(logparser TO_TIME output not matching the sql time datatype)

logparser TO_TIME输出与sql时间数据类型不匹配(logparser TO_TIME output not matching the sql time datatype)

以下是logparser的QUERY:

logparser -i:Textline "SELECT TO_DATE(TO_TIMESTAMP(TRIM(EXTRACT_SUFFIX(text,0,'TIMESTAMP')),'M/d/yyyy'))AS DATE, TO_TIME(TO_TIMESTAMP(TRIM(EXTRACT_TOKEN(text,0,'(')),'H:mm:ss')) as TIME from 'C:\xxxx.log' where text like '%OUT:%' OR text like '%IN:%' OR text like '%TIMESTAMP%' OR text like '%DENIED%'" -o:datagrid

输出的查询是:

DATE           TIME
NULL           03:09:49
NULL           03:09:49
NULL           03:10:44
NULL           03:11:52
2015-02-06     03:12:40
NULL           03:13:37
NULL           03:18:22
NULL           03:21:18
NULL           03:21:32
NULL           03:24:19
NULL           03:26:02

当我希望这些数据流入SQL表时,我收到以下错误:

QUERY:

logparser -i:Textline "select TO_DATE(TO_TIMESTAMP(TRIM(EXTRACT_SUFFIX(text,0,'TIMESTAMP')),'M/d/yyyy'))AS DATE, TO_TIME(TO_TIMESTAMP(TRIM(EXTRACT_TOKEN(text,0,'(')),'H:mm:ss')) as TIME INTO Ptclog from 'C:\ptclmgrd.log' where text like '%OUT:%' OR text like '%IN:%' OR text like '%TIMESTAMP%' OR text like '%DENIED%'" -o:SQL -server:KANNA\SQLEXPRESS -database:Flex -driver:"SQL Server Native Client 11.0" -username:sa -password:XXXXXX

错误:

任务中止。 SQL表列“Time”数据类型与SELECT子句项“TIME”(类型TIMESTAMP)不兼容

在SQLEXPRESS中选择的数据类型是

时间(0)。

如果我选择数据类型,数据将流向列:

“约会时间”

但这会在时间前添加一个令人讨厌的默认日期。 例如,时间显示为:

DATE        TIME
2015-02-06  2015-01-01 03:12:40.000
NULL        2015-01-01 07:55:49.000
NULL        2015-01-01 06:46:50.000
NULL        2015-01-01 06:55:40.000
NULL        2015-01-01 01:57:25.000
NULL        2015-01-01 02:36:41.000

有没有办法在sql express 2014 DB中以hh:mm:ss格式表示时间?

以下是正在查询的日志文件中的示例条目:

3:12:40 (lmgrd) TIMESTAMP 2/6/2015
3:13:37 (ptc_d) OUT: "PROE_Flex3CG" e1cx@D43F2STC  
3:18:22 (ptc_d) OUT: "PROE_Flex3C" u234566@D5712Sf8  
3:21:18 (ptc_d) OUT: "PROE_Flex3C" u234566@D5712Sf8  
3:21:32 (ptc_d) OUT: "PROE_Flex3C" U524863@D9NR972S  
3:24:19 (ptc_d) IN: "PROE_Flex3CG" e1cx@D43F2STC  
3:26:02 (ptc_d) OUT: "PROE_Flex3C" m0ax@2SD3TC3F  
3:26:46 (ptc_d) OUT: "PROE_Flex3C" 06u1015@03tjn-proe  
3:26:48 (ptc_d) OUT: "26" 06u1015@03tjn-proe  
3:26:48 (ptc_d) OUT: "10114" 06u1015@03tjn-proe  
4:34:39 (ptc_d) DENIED: "26" 74U1027@MZBOXSGH61108  (Licensed number of users already reached. (-4,342:10054 ""))

Following is the QUERY from logparser :

logparser -i:Textline "SELECT TO_DATE(TO_TIMESTAMP(TRIM(EXTRACT_SUFFIX(text,0,'TIMESTAMP')),'M/d/yyyy'))AS DATE, TO_TIME(TO_TIMESTAMP(TRIM(EXTRACT_TOKEN(text,0,'(')),'H:mm:ss')) as TIME from 'C:\xxxx.log' where text like '%OUT:%' OR text like '%IN:%' OR text like '%TIMESTAMP%' OR text like '%DENIED%'" -o:datagrid

Output of the query is :

DATE           TIME
NULL           03:09:49
NULL           03:09:49
NULL           03:10:44
NULL           03:11:52
2015-02-06     03:12:40
NULL           03:13:37
NULL           03:18:22
NULL           03:21:18
NULL           03:21:32
NULL           03:24:19
NULL           03:26:02

When i want this data to flow into SQL table I get the following error:

QUERY :

logparser -i:Textline "select TO_DATE(TO_TIMESTAMP(TRIM(EXTRACT_SUFFIX(text,0,'TIMESTAMP')),'M/d/yyyy'))AS DATE, TO_TIME(TO_TIMESTAMP(TRIM(EXTRACT_TOKEN(text,0,'(')),'H:mm:ss')) as TIME INTO Ptclog from 'C:\ptclmgrd.log' where text like '%OUT:%' OR text like '%IN:%' OR text like '%TIMESTAMP%' OR text like '%DENIED%'" -o:SQL -server:KANNA\SQLEXPRESS -database:Flex -driver:"SQL Server Native Client 11.0" -username:sa -password:XXXXXX

ERROR:

Task aborted. SQL table column "Time" data type is not compatible with SELECT clause item "TIME" (type TIMESTAMP)

The data type selected in SQLEXPRESS is

time(0).

The data flows to the column if i select the datatype as :

"datetime"

But this adds a default date in front of time which is nuisance. e.g the time is shown as :

DATE        TIME
2015-02-06  2015-01-01 03:12:40.000
NULL        2015-01-01 07:55:49.000
NULL        2015-01-01 06:46:50.000
NULL        2015-01-01 06:55:40.000
NULL        2015-01-01 01:57:25.000
NULL        2015-01-01 02:36:41.000

Is there a way the time can be represented in hh:mm:ss format in sql express 2014 DB ?

Following are sample entries in the log file that is being queried:

3:12:40 (lmgrd) TIMESTAMP 2/6/2015
3:13:37 (ptc_d) OUT: "PROE_Flex3CG" e1cx@D43F2STC  
3:18:22 (ptc_d) OUT: "PROE_Flex3C" u234566@D5712Sf8  
3:21:18 (ptc_d) OUT: "PROE_Flex3C" u234566@D5712Sf8  
3:21:32 (ptc_d) OUT: "PROE_Flex3C" U524863@D9NR972S  
3:24:19 (ptc_d) IN: "PROE_Flex3CG" e1cx@D43F2STC  
3:26:02 (ptc_d) OUT: "PROE_Flex3C" m0ax@2SD3TC3F  
3:26:46 (ptc_d) OUT: "PROE_Flex3C" 06u1015@03tjn-proe  
3:26:48 (ptc_d) OUT: "26" 06u1015@03tjn-proe  
3:26:48 (ptc_d) OUT: "10114" 06u1015@03tjn-proe  
4:34:39 (ptc_d) DENIED: "26" 74U1027@MZBOXSGH61108  (Licensed number of users already reached. (-4,342:10054 ""))

原文:https://stackoverflow.com/questions/29144624
更新时间:2024-02-02 10:02

最满意答案

JavaFX 2.2中没有标准的水平方向TitledPane。

您可以在JavaFX问题跟踪器中为其创建功能请求。

实现自己的水平TitledPane非常简单。

这是一个类似的东西演示,只是在标准窗格上使用动画。

所涉及技术的进一步解释在Sai的博客文章中: 在JavaFX中滑动(这完全是关于剪辑)

侧边栏可见侧边栏隐藏

/** Animates a node on and off screen to the left. */
class SideBar extends VBox {
  /** @return a control button to hide and show the sidebar */
  public Button getControlButton() { return controlButton; }
  private final Button controlButton;

  /** creates a sidebar containing a vertical alignment of the given nodes */
  SideBar(final double expandedWidth, Node... nodes) {
    getStyleClass().add("sidebar");
    this.setPrefWidth(expandedWidth);

    // create a bar to hide and show.
    setAlignment(Pos.CENTER);
    getChildren().addAll(nodes);

    // create a button to hide and show the sidebar.
    controlButton = new Button("Collapse");
    controlButton.getStyleClass().add("hide-left");

    // apply the animations when the button is pressed.
    controlButton.setOnAction(new EventHandler<ActionEvent>() {
      @Override public void handle(ActionEvent actionEvent) {
        // create an animation to hide sidebar.
        final Animation hideSidebar = new Transition() {
          { setCycleDuration(Duration.millis(250)); }
          protected void interpolate(double frac) {
            final double curWidth = expandedWidth * (1.0 - frac);
            setPrefWidth(curWidth);
            setTranslateX(-expandedWidth + curWidth);
          }
        };
        hideSidebar.onFinishedProperty().set(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            setVisible(false);
            controlButton.setText("Show");
            controlButton.getStyleClass().remove("hide-left");
            controlButton.getStyleClass().add("show-right");
          }
        });

        // create an animation to show a sidebar.
        final Animation showSidebar = new Transition() {
          { setCycleDuration(Duration.millis(250)); }
          protected void interpolate(double frac) {
            final double curWidth = expandedWidth * frac;
            setPrefWidth(curWidth);
            setTranslateX(-expandedWidth + curWidth);
          }
        };
        showSidebar.onFinishedProperty().set(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            controlButton.setText("Collapse");
            controlButton.getStyleClass().add("hide-left");
            controlButton.getStyleClass().remove("show-right");
          }
        });

        if (showSidebar.statusProperty().get() == Animation.Status.STOPPED && hideSidebar.statusProperty().get() == Animation.Status.STOPPED) {
          if (isVisible()) {
            hideSidebar.play();
          } else {
            setVisible(true);
            showSidebar.play();
          }
        }
      }
    });
  }
}

There is no standard horizontal orientation TitledPane in JavaFX 2.2.

You can create a feature request for one in the JavaFX issue tracker.

Implementing your own horizontal TitledPane is pretty easy.

Here is a demo of a similar thing just using animation on a standard Pane.

Further explanations of the techniques involved are in Sai's blog post: Sliding in JavaFX (It’s all about clipping).

sidebar visible sidebar hidden

/** Animates a node on and off screen to the left. */
class SideBar extends VBox {
  /** @return a control button to hide and show the sidebar */
  public Button getControlButton() { return controlButton; }
  private final Button controlButton;

  /** creates a sidebar containing a vertical alignment of the given nodes */
  SideBar(final double expandedWidth, Node... nodes) {
    getStyleClass().add("sidebar");
    this.setPrefWidth(expandedWidth);

    // create a bar to hide and show.
    setAlignment(Pos.CENTER);
    getChildren().addAll(nodes);

    // create a button to hide and show the sidebar.
    controlButton = new Button("Collapse");
    controlButton.getStyleClass().add("hide-left");

    // apply the animations when the button is pressed.
    controlButton.setOnAction(new EventHandler<ActionEvent>() {
      @Override public void handle(ActionEvent actionEvent) {
        // create an animation to hide sidebar.
        final Animation hideSidebar = new Transition() {
          { setCycleDuration(Duration.millis(250)); }
          protected void interpolate(double frac) {
            final double curWidth = expandedWidth * (1.0 - frac);
            setPrefWidth(curWidth);
            setTranslateX(-expandedWidth + curWidth);
          }
        };
        hideSidebar.onFinishedProperty().set(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            setVisible(false);
            controlButton.setText("Show");
            controlButton.getStyleClass().remove("hide-left");
            controlButton.getStyleClass().add("show-right");
          }
        });

        // create an animation to show a sidebar.
        final Animation showSidebar = new Transition() {
          { setCycleDuration(Duration.millis(250)); }
          protected void interpolate(double frac) {
            final double curWidth = expandedWidth * frac;
            setPrefWidth(curWidth);
            setTranslateX(-expandedWidth + curWidth);
          }
        };
        showSidebar.onFinishedProperty().set(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent actionEvent) {
            controlButton.setText("Collapse");
            controlButton.getStyleClass().add("hide-left");
            controlButton.getStyleClass().remove("show-right");
          }
        });

        if (showSidebar.statusProperty().get() == Animation.Status.STOPPED && hideSidebar.statusProperty().get() == Animation.Status.STOPPED) {
          if (isVisible()) {
            hideSidebar.play();
          } else {
            setVisible(true);
            showSidebar.play();
          }
        }
      }
    });
  }
}

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。