小编m.a*_*bin的帖子

如何正确传递JDBC url中的会话变量?

我必须增加group_concat_max_len.我不能通过preparestatement做到这一点,我也不能在mysql my.conf文件中做到这一点.

我在mysql文档中发现有一个选项可以在url中传递会话变量.但是没有例子,我试着这样做:

jdbc.url=jdbc:mysql://xxxx.xx.xx.xx/dbName?sessionVariables=group_concat_max_len:204800
Run Code Online (Sandbox Code Playgroud)

我有这个例外:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':204800' at line 1
Run Code Online (Sandbox Code Playgroud)

我也像这样尝试过:

jdbc.url=jdbc:mysql://xxxx.xx.xx.xx/dbName?sessionVariables=group_concat_max_len,204800
Run Code Online (Sandbox Code Playgroud)

因为官方文件说:

sessionVariables

A comma-separated list of name/value pairs to be sent as SET SESSION ... to the server when the driver connects.

Since version: 3.1.8
Run Code Online (Sandbox Code Playgroud)

有任何想法吗???

java mysql jdbc

10
推荐指数
3
解决办法
6423
查看次数

从嵌套的JSON对象中检索值

我有JSON文件,我想解析.JSON文件("myfile")的格式如下:

{
    "LanguageLevels": {
        "1": "Pocz?tkuj?cy",
        "2": "?rednioZaawansowany",
        "3": "Zaawansowany",
        "4": "Ekspert"
    }
}
Run Code Online (Sandbox Code Playgroud)

我想从语言级别中检索Key 2的值(ŚrednioZaawansowany).

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Iterator;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

public class JsonSimpleExample {
public static void main(String[] args) {

JSONParser parser = new JSONParser();

try {

    Object obj = parser.parse(new FileReader("myfile"); 
    JSONObject jsonObject = (JSONObject) obj;
    JSONObject jsonChildObject = (JSONObject)jsonObject.get("LanguageLevels");
Run Code Online (Sandbox Code Playgroud)

接下来做什么?我如何迭代它?

java parsing json nested

8
推荐指数
3
解决办法
8万
查看次数

Spring社交facebook登录错误 - 数字值超出int范围

我使用Spring Social时遇到问题,当我尝试登录Facebook时,出现以下错误:

org.springframework.social.facebook.api.User["video_upload_limits"]->org.springframework.social.facebook.api.VideoUploadLimits["size"])

com.fasterxml.jackson.databind.JsonMappingException: Numeric value (2505397589) out of range of int
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助.

maven依赖:

春季4.2.0.RELEASE

    <!-- Spring Social -->
    <dependency>
        <groupId>org.springframework.social</groupId>
        <artifactId>spring-social-core</artifactId>
        <version>1.1.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.social</groupId>
        <artifactId>spring-social-web</artifactId>
        <version>1.1.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.social</groupId>
        <artifactId>spring-social-facebook</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>

    <!-- jason -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.6.2</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.6.2</version>
    </dependency>

    ==> same error when version up to 2.7.0-rc1(jackson)
Run Code Online (Sandbox Code Playgroud)

代码:

String authorizationCode = request.getParameter("code");

FacebookConnectionFactory connectionFactory = new FacebookConnectionFactory(this.appId, this.appSecret);

OAuth2Operations oauthOperations = connectionFactory.getOAuthOperations();

AccessGrant accessGrant = oauthOperations.exchangeForAccess(authorizationCode, RequestUtil.getRedirectionURLForSNSSignUp(request, …
Run Code Online (Sandbox Code Playgroud)

spring facebook login jackson spring-social-facebook

7
推荐指数
1
解决办法
1649
查看次数

Thymeleaf 迭代对象列表

我在迭代 Thymeleaf 中的对象列表时遇到问题。这是我的 HTML:

<input th:each="a,iterStatus : currentQuestion.answers" type="radio" name="answer" th:text="${a.answer}" th:value="${iterStatus.index}"></input>
Run Code Online (Sandbox Code Playgroud)

这是控制器类:

@RequestMapping(value={ "/exam", "/exam/" }, method = RequestMethod.GET)
public String exam(Model model){

    if (!sessionPreferences.isExamStarted()){
        sessionPreferences.setQuestionList(questionService.list(Questions.findAll().paginate(0, 5).loadWith("answers")));
        sessionPreferences.setCurrentQuestion(questionService.uniqueObject(Questions.findAll().withId(1L).loadWith("answers")));
    }
    model.addAttribute("currentQuestion", sessionPreferences.getCurrentQuestion());
    sessionPreferences.setExamStarted(true);
    System.out.println("TRUE!");
    System.out.println(sessionPreferences.getCurrentQuestion().getAnswers().size());
    System.out.println(sessionPreferences.getCurrentQuestion().getAnswers().get(0));
    return "exam";
}
Run Code Online (Sandbox Code Playgroud)

这是 SessionPreferences 类:

@Component
@Scope(value="session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class SessionPreferences implements Serializable {

private static final long serialVersionUID = -3875093750700352970L;

@Setter
private String displayName;

@Setter @Getter
private Question currentQuestion;

@Getter @Setter
private boolean examStarted;

@Getter @Setter
private Map<Question, Integer> selections …
Run Code Online (Sandbox Code Playgroud)

html java spring thymeleaf

1
推荐指数
1
解决办法
5431
查看次数