What is the default username and password for h2 when there's nothing explicit in JDBC?

后端 未结 7 949
你的背包
你的背包 2021-02-06 21:47

From a program, I created a H2 database without specifying any user or password in the JDBC URL.

Now I\'m trying to access that database with the Script tool. The doc sa

相关标签:
7条回答
  • 2021-02-06 22:24

    in my case i had mispelled the username and password properties, so i assume spring tried to use the defaults which didn't work

    0 讨论(0)
  • 2021-02-06 22:28

    This might work:

    name = "sa"
    password = ""
    
    0 讨论(0)
  • 2021-02-06 22:32

    In your application.properties file please add

           spring.datasource.username=username
           spring.datasource.password=password
    

    hope it helps

    0 讨论(0)
  • 2021-02-06 22:34

    Note: If you are getting this error when trying to login via Intellij, you need to enable MIXED_MODE. See this answer for more details: Connect to H2 database using IntelliJ database client

    0 讨论(0)
  • 2021-02-06 22:40

    In case you got stuck with the default non-blank user when running the client, the full set of parameters will get you past that:

    java -cp <path_to_h2>\h2.jar org.h2.tools.Shell -url "jdbc:h2:file:<jdbc_url>" -driver "org.h2.Driver" -user "" -password ""
    
    0 讨论(0)
  • 2021-02-06 22:43

    try this:

    java -cp h2*.jar org.h2.tools.Script -user "sa" -password "" -url "jdbc:h2:path_to_your_db_file"
    
    0 讨论(0)
提交回复
热议问题